diff --git a/src/main/java/com/gmail/nossr50/listeners/PlayerListener.java b/src/main/java/com/gmail/nossr50/listeners/PlayerListener.java index 5bd715662..f487a09ef 100644 --- a/src/main/java/com/gmail/nossr50/listeners/PlayerListener.java +++ b/src/main/java/com/gmail/nossr50/listeners/PlayerListener.java @@ -121,8 +121,21 @@ public class PlayerListener implements Listener { // we only care about players as this is for fixing player death messages if (!(event.getEntity() instanceof Player)) return; - if (!(event.getDamager() instanceof LivingEntity)) + Player player = (Player) event.getEntity(); + + // get the attacker + LivingEntity attacker; + if (event.getDamager() instanceof LivingEntity) + attacker = (LivingEntity) event.getDamager(); + // attempt to find creator of a projectile + else if (event.getDamager() instanceof Projectile && ((Projectile) event.getDamager()).getShooter() instanceof LivingEntity) + attacker = (LivingEntity) ((Projectile) event.getDamager()).getShooter(); + else return; + + if (attacker instanceof HumanEntity) + return; + // world blacklist check if (WorldBlacklist.isWorldBlacklisted(event.getEntity().getWorld())) return; @@ -130,9 +143,6 @@ public class PlayerListener implements Listener { if (WorldGuardUtils.isWorldGuardLoaded() && !WorldGuardManager.getInstance().hasMainFlag((Player) event.getEntity())) return; - Player player = (Player) event.getEntity(); - LivingEntity attacker = (LivingEntity) event.getDamager(); - // we only want to handle player deaths if ((player.getHealth() - event.getFinalDamage()) > 0) return;