From 789740c358b3fd9c384b8aab6ee8c39c85aa5060 Mon Sep 17 00:00:00 2001 From: libraryaddict Date: Sun, 16 Mar 2014 09:05:12 +1300 Subject: [PATCH] Add a option to only remove the disguise when it is invalid, only remove the current disguise. --- .../disguise/disguisetypes/Disguise.java | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/me/libraryaddict/disguise/disguisetypes/Disguise.java b/src/me/libraryaddict/disguise/disguisetypes/Disguise.java index 126d9132..a8e600c8 100644 --- a/src/me/libraryaddict/disguise/disguisetypes/Disguise.java +++ b/src/me/libraryaddict/disguise/disguisetypes/Disguise.java @@ -37,6 +37,7 @@ public abstract class Disguise { private boolean hideArmorFromSelf = DisguiseConfig.isHidingArmorFromSelf(); private boolean hideHeldItemFromSelf = DisguiseConfig.isHidingHeldItemFromSelf(); private boolean modifyBoundingBox = DisguiseConfig.isModifyBoundingBox(); + private boolean removeWhenInvalid; private boolean replaceSounds = DisguiseConfig.isSoundEnabled(); private BukkitRunnable velocityRunnable; private boolean velocitySent = DisguiseConfig.isVelocitySent(); @@ -184,7 +185,9 @@ public abstract class Disguise { public void run() { // If entity is no longer valid. Remove it. if (!getEntity().isValid()) { - DisguiseAPI.undisguiseToAll(getEntity()); + if (isRemoveWhenInvalid()) { + removeDisguise(); + } } else { // If the disguise type is tnt, we need to resend the entity packet else it will turn invisible if (getType() == DisguiseType.PRIMED_TNT || getType() == DisguiseType.FIREWORK) { @@ -326,6 +329,10 @@ public abstract class Disguise { return false; } + public boolean isRemoveWhenInvalid() { + return !removeWhenInvalid; + } + public boolean isSelfDisguiseSoundsReplaced() { return hearSelfDisguise; } @@ -432,6 +439,10 @@ public abstract class Disguise { } } + public void setRemoveDisguiseWhenInvalid(boolean removeWhenInvalid) { + this.removeWhenInvalid = removeWhenInvalid; + } + public void setReplaceSounds(boolean areSoundsReplaced) { replaceSounds = areSoundsReplaced; }