From dd3017b0f9a78c911feebe8f9503f8dd26f24b3f Mon Sep 17 00:00:00 2001 From: libraryaddict Date: Tue, 4 Feb 2020 16:10:08 +1300 Subject: [PATCH] Check if at least one of the people fighting is human --- .../disguise/DisguiseListener.java | 21 ++++++++++--------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/src/main/java/me/libraryaddict/disguise/DisguiseListener.java b/src/main/java/me/libraryaddict/disguise/DisguiseListener.java index 730682a0..62924c3b 100644 --- a/src/main/java/me/libraryaddict/disguise/DisguiseListener.java +++ b/src/main/java/me/libraryaddict/disguise/DisguiseListener.java @@ -25,10 +25,7 @@ import org.bukkit.Bukkit; import org.bukkit.Location; import org.bukkit.World; import org.bukkit.command.CommandSender; -import org.bukkit.entity.Entity; -import org.bukkit.entity.LivingEntity; -import org.bukkit.entity.Player; -import org.bukkit.entity.Projectile; +import org.bukkit.entity.*; import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; import org.bukkit.event.Listener; @@ -202,18 +199,22 @@ public class DisguiseListener implements Listener { @EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true) public void onAttack(EntityDamageByEntityEvent event) { - if (event.getEntity() instanceof Player) { - if (DisguiseConfig.isDisguiseBlownWhenAttacked()) { - checkPlayerCanBlowDisguise((Player) event.getEntity()); - } - } - Entity attacker = event.getDamager(); if (attacker instanceof Projectile && ((Projectile) attacker).getShooter() instanceof Player) { attacker = (Entity) ((Projectile) attacker).getShooter(); } + if (event.getEntityType() != EntityType.PLAYER && !(attacker instanceof Player)) { + return; + } + + if (event.getEntity() instanceof Player) { + if (DisguiseConfig.isDisguiseBlownWhenAttacked()) { + checkPlayerCanBlowDisguise((Player) event.getEntity()); + } + } + checkPlayerCanFight(event, attacker); if (attacker instanceof Player) {