1
0
mirror of https://github.com/Zrips/Jobs.git synced 2024-12-27 03:17:49 +01:00

Lets use EntityDamageByEntityEvent to get killer

This commit is contained in:
Zrips 2024-10-16 15:33:20 +03:00
parent 5d823a1d81
commit 1d3b15ab87

View File

@ -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();
}