Blow disguise for attackers as well

This commit is contained in:
libraryaddict 2014-03-03 10:22:29 +13:00
parent cb58cdd8d3
commit 143f72a20f

View File

@ -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 @EventHandler
public void onAttack(EntityDamageByEntityEvent event) { public void onAttack(EntityDamageByEntityEvent event) {
if (DisguiseConfig.isDisguiseBlownOnAttack() && event.getEntity() instanceof Player) { if (DisguiseConfig.isDisguiseBlownOnAttack()) {
Disguise[] disguises = DisguiseAPI.getDisguises(event.getEntity()); if (event.getEntity() instanceof Player) {
if (disguises.length > 0) { checkPlayer((Player) event.getEntity());
DisguiseAPI.undisguiseToAll(event.getEntity());
if (DisguiseConfig.getDisguiseBlownMessage().length() > 0) {
((Player) event.getEntity()).sendMessage(DisguiseConfig.getDisguiseBlownMessage());
} }
if (event.getDamager() instanceof Player) {
checkPlayer((Player) event.getDamager());
} }
} }
} }