From 1d3b15ab87b61cb85533256d556571568ad39af0 Mon Sep 17 00:00:00 2001 From: Zrips Date: Wed, 16 Oct 2024 15:33:20 +0300 Subject: [PATCH] Lets use EntityDamageByEntityEvent to get killer --- .../com/gamingmesh/jobs/listeners/JobsPaymentListener.java | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/main/java/com/gamingmesh/jobs/listeners/JobsPaymentListener.java b/src/main/java/com/gamingmesh/jobs/listeners/JobsPaymentListener.java index a6483bfc..079b34c3 100644 --- a/src/main/java/com/gamingmesh/jobs/listeners/JobsPaymentListener.java +++ b/src/main/java/com/gamingmesh/jobs/listeners/JobsPaymentListener.java @@ -1305,9 +1305,10 @@ public final class JobsPaymentListener implements Listener { if (!(event.getEntity().getLastDamageCause() instanceof EntityDamageByEntityEvent)) { killer = entityLastDamager.getIfPresent(event.getEntity().getUniqueId()); - } else if (event.getEntity().getLastDamageCause().getCause() == EntityDamageEvent.DamageCause.PROJECTILE) { - if (event.getEntity().getLastDamageCause().getDamageSource() != null) - killer = event.getEntity().getLastDamageCause().getDamageSource().getCausingEntity(); + } else if (event.getEntity().getLastDamageCause() instanceof EntityDamageByEntityEvent) { + EntityDamageByEntityEvent entityEvent = (EntityDamageByEntityEvent) event.getEntity().getLastDamageCause(); + if (entityEvent.getDamager() != null) + killer = entityEvent.getDamager(); } else { killer = ((EntityDamageByEntityEvent) event.getEntity().getLastDamageCause()).getDamager(); }