Fix deaths from skeletons showing health bars (#4483)

* Fix deaths from skeletons showing health bars

* Ignore human attackers
This commit is contained in:
lexikiq 2021-04-09 10:59:42 -04:00 committed by GitHub
parent 56f9341f8e
commit e7978a6ad9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -121,8 +121,21 @@ public class PlayerListener implements Listener {
// we only care about players as this is for fixing player death messages // we only care about players as this is for fixing player death messages
if (!(event.getEntity() instanceof Player)) if (!(event.getEntity() instanceof Player))
return; 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; return;
if (attacker instanceof HumanEntity)
return;
// world blacklist check // world blacklist check
if (WorldBlacklist.isWorldBlacklisted(event.getEntity().getWorld())) if (WorldBlacklist.isWorldBlacklisted(event.getEntity().getWorld()))
return; return;
@ -130,9 +143,6 @@ public class PlayerListener implements Listener {
if (WorldGuardUtils.isWorldGuardLoaded() && !WorldGuardManager.getInstance().hasMainFlag((Player) event.getEntity())) if (WorldGuardUtils.isWorldGuardLoaded() && !WorldGuardManager.getInstance().hasMainFlag((Player) event.getEntity()))
return; return;
Player player = (Player) event.getEntity();
LivingEntity attacker = (LivingEntity) event.getDamager();
// we only want to handle player deaths // we only want to handle player deaths
if ((player.getHealth() - event.getFinalDamage()) > 0) if ((player.getHealth() - event.getFinalDamage()) > 0)
return; return;