From 143f72a20fc03b52bb614e4013ce7ba0ec5cd9bd Mon Sep 17 00:00:00 2001 From: libraryaddict Date: Mon, 3 Mar 2014 10:22:29 +1300 Subject: [PATCH] Blow disguise for attackers as well --- .../disguise/DisguiseListener.java | 23 +++++++++++++------ 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/src/me/libraryaddict/disguise/DisguiseListener.java b/src/me/libraryaddict/disguise/DisguiseListener.java index d8273a06..7df9cf30 100644 --- a/src/me/libraryaddict/disguise/DisguiseListener.java +++ b/src/me/libraryaddict/disguise/DisguiseListener.java @@ -64,15 +64,24 @@ public class DisguiseListener implements Listener { } } + private void checkPlayer(Player entity) { + Disguise[] disguises = DisguiseAPI.getDisguises(entity); + if (disguises.length > 0) { + DisguiseAPI.undisguiseToAll(entity); + if (DisguiseConfig.getDisguiseBlownMessage().length() > 0) { + entity.sendMessage(DisguiseConfig.getDisguiseBlownMessage()); + } + } + } + @EventHandler public void onAttack(EntityDamageByEntityEvent event) { - if (DisguiseConfig.isDisguiseBlownOnAttack() && event.getEntity() instanceof Player) { - Disguise[] disguises = DisguiseAPI.getDisguises(event.getEntity()); - if (disguises.length > 0) { - DisguiseAPI.undisguiseToAll(event.getEntity()); - if (DisguiseConfig.getDisguiseBlownMessage().length() > 0) { - ((Player) event.getEntity()).sendMessage(DisguiseConfig.getDisguiseBlownMessage()); - } + if (DisguiseConfig.isDisguiseBlownOnAttack()) { + if (event.getEntity() instanceof Player) { + checkPlayer((Player) event.getEntity()); + } + if (event.getDamager() instanceof Player) { + checkPlayer((Player) event.getDamager()); } } }