1
0
mirror of https://github.com/Zrips/Jobs.git synced 2024-11-29 05:55:27 +01:00

Check for possible NULL on entity death

This commit is contained in:
Zrips 2024-09-28 11:32:03 +03:00
parent 98dbc51f87
commit fed6ef1355

View File

@ -1301,12 +1301,13 @@ public final class JobsPaymentListener implements Listener {
return;
LivingEntity lVictim = event.getEntity();
Entity killer;
Entity killer = null;
if (!(event.getEntity().getLastDamageCause() instanceof EntityDamageByEntityEvent)) {
killer = entityLastDamager.getIfPresent(event.getEntity().getUniqueId());
} else if (event.getEntity().getLastDamageCause().getCause() == EntityDamageEvent.DamageCause.PROJECTILE) {
killer = event.getEntity().getLastDamageCause().getDamageSource().getCausingEntity();
if (event.getEntity().getLastDamageCause().getDamageSource() != null)
killer = event.getEntity().getLastDamageCause().getDamageSource().getCausingEntity();
} else {
killer = ((EntityDamageByEntityEvent) event.getEntity().getLastDamageCause()).getDamager();
}