diff --git a/config.yml b/config.yml index a41ffda5..a69abfa0 100644 --- a/config.yml +++ b/config.yml @@ -23,4 +23,8 @@ SendVelocity: true # However! This doesn't actually remove the armor! # It just makes the client think the armor was removed so that it doesn't render it! RemoveArmor: true -RemoveHeldItem: true \ No newline at end of file +RemoveHeldItem: true +# If you set a disguise to burning, it will no longer be able to be shown as sneaking or invisible. +# Set this to true if you want the disguise to get the animations of the disguised entity. Such as invisible, on fire, sprinting, sneaking, blocking +# This is only valid if you set a animation on the disguise itself. Because the entitys animations are applied otherwise. +AddEntityAnimations: false \ No newline at end of file diff --git a/src/me/libraryaddict/disguise/DisguiseAPI.java b/src/me/libraryaddict/disguise/DisguiseAPI.java index 7ae91095..d230d7af 100644 --- a/src/me/libraryaddict/disguise/DisguiseAPI.java +++ b/src/me/libraryaddict/disguise/DisguiseAPI.java @@ -13,11 +13,11 @@ import org.bukkit.entity.Entity; public class DisguiseAPI { private static boolean hearSelfDisguise; - private static boolean hidingArmor; private static boolean hidingHeldItem; + private static boolean isEntityAnimationsAdded; private static boolean sendVelocity; - + @Deprecated public static boolean canHearSelfDisguise() { return hearSelfDisguise; @@ -107,6 +107,10 @@ public class DisguiseAPI { return getDisguise(disguised) != null; } + public static boolean isEntityAnimationsAdded() { + return isEntityAnimationsAdded; + } + /** * Is the plugin modifying the inventory packets so that players when self disguised, do not see their armor floating around */ @@ -150,6 +154,10 @@ public class DisguiseAPI { return PacketsManager.isViewDisguisesListenerEnabled(); } + public static void setAddEntityAnimations(boolean isEntityAnimationsAdded) { + DisguiseAPI.isEntityAnimationsAdded = isEntityAnimationsAdded; + } + /** * Can players hear their own disguises */ diff --git a/src/me/libraryaddict/disguise/LibsDisguises.java b/src/me/libraryaddict/disguise/LibsDisguises.java index d78134a4..6302f62c 100644 --- a/src/me/libraryaddict/disguise/LibsDisguises.java +++ b/src/me/libraryaddict/disguise/LibsDisguises.java @@ -63,6 +63,7 @@ public class LibsDisguises extends JavaPlugin { DisguiseAPI.setHearSelfDisguise(getConfig().getBoolean("HearSelfDisguise")); DisguiseAPI.setHideArmorFromSelf(getConfig().getBoolean("RemoveArmor")); DisguiseAPI.setHideHeldItemFromSelf(getConfig().getBoolean("RemoveHeldItem")); + DisguiseAPI.setAddEntityAnimations(getConfig().getBoolean("AddEntityAnimations")); if (DisguiseAPI.isHidingArmorFromSelf() || DisguiseAPI.isHidingHeldItemFromSelf()) { DisguiseAPI.setInventoryListenerEnabled(true); } diff --git a/src/me/libraryaddict/disguise/disguisetypes/FlagWatcher.java b/src/me/libraryaddict/disguise/disguisetypes/FlagWatcher.java index a2fda793..a4a4c5f6 100644 --- a/src/me/libraryaddict/disguise/disguisetypes/FlagWatcher.java +++ b/src/me/libraryaddict/disguise/disguisetypes/FlagWatcher.java @@ -36,6 +36,7 @@ public class FlagWatcher { } } + private boolean addEntityAnimations = DisguiseAPI.isEntityAnimationsAdded(); /** * This is the entity values I need to add else it could crash them.. */ @@ -44,6 +45,7 @@ public class FlagWatcher { private HashMap entityValues = new HashMap(); private boolean hasDied; private org.bukkit.inventory.ItemStack[] items = new org.bukkit.inventory.ItemStack[5]; + private HashSet modifiedEntityAnimations = new HashSet(); public FlagWatcher(Disguise disguise) { this.disguise = disguise; @@ -63,6 +65,7 @@ public class FlagWatcher { } cloned.entityValues = (HashMap) entityValues.clone(); cloned.items = items.clone(); + cloned.modifiedEntityAnimations = (HashSet) modifiedEntityAnimations.clone(); return cloned; } @@ -90,6 +93,16 @@ public class FlagWatcher { value = backupEntityValues.get(dataType); } if (value != null) { + if (addEntityAnimations && dataType == 0) { + byte watcher = (Byte) watch.getValue(); + byte valueByte = (Byte) value; + for (int i = 0; i < 6; i++) { + if ((watcher & 1 << i) != 0 && !modifiedEntityAnimations.contains(i)) { + valueByte = (byte) (valueByte | 1 << i); + } + } + value = valueByte; + } boolean doD = watch.getDirtyState(); watch = new WrappedWatchableObject(dataType, value); if (!doD) @@ -177,6 +190,10 @@ public class FlagWatcher { return getFlag(0); } + public boolean isEntityAnimationsAdded() { + return addEntityAnimations; + } + public boolean isInvisible() { return getFlag(5); } @@ -222,6 +239,10 @@ public class FlagWatcher { } } + public void setAddEntityAnimations(boolean isEntityAnimationsAdded) { + this.addEntityAnimations = isEntityAnimationsAdded; + } + public void setArmor(org.bukkit.inventory.ItemStack[] itemstack) { for (int i = 0; i < itemstack.length; i++) setItemStack(i, itemstack[i]); @@ -237,8 +258,10 @@ public class FlagWatcher { } protected void setFlag(int no, int i, boolean flag) { + if (no == 0) { + modifiedEntityAnimations.add(i); + } byte b0 = (Byte) getValue(no, (byte) 0); - if (flag) { setValue(no, (byte) (b0 | 1 << i)); } else { diff --git a/src/me/libraryaddict/disguise/disguisetypes/watchers/GhastWatcher.java b/src/me/libraryaddict/disguise/disguisetypes/watchers/GhastWatcher.java index c6568712..b17bdb93 100644 --- a/src/me/libraryaddict/disguise/disguisetypes/watchers/GhastWatcher.java +++ b/src/me/libraryaddict/disguise/disguisetypes/watchers/GhastWatcher.java @@ -8,18 +8,12 @@ public class GhastWatcher extends LivingWatcher { super(disguise); } - @Deprecated - public boolean isAgressive() { + public boolean isAggressive() { return (Byte) getValue(16, (byte) 0) == 1; } @Deprecated - public void setAgressive(boolean isAgressive) { - setValue(16, (byte) (isAgressive ? 1 : 0)); - sendData(16); - } - - public boolean isAggressive() { + public boolean isAgressive() { return (Byte) getValue(16, (byte) 0) == 1; } @@ -28,4 +22,10 @@ public class GhastWatcher extends LivingWatcher { sendData(16); } + @Deprecated + public void setAgressive(boolean isAgressive) { + setValue(16, (byte) (isAgressive ? 1 : 0)); + sendData(16); + } + }