From b6fca92817026740cebf203c04b62ae28ada76ef Mon Sep 17 00:00:00 2001 From: libraryaddict Date: Thu, 3 Apr 2014 01:49:48 +1300 Subject: [PATCH 1/7] Change self disguises to use UUID's instead of integers as the key --- src/me/libraryaddict/disguise/DisguiseAPI.java | 3 ++- .../disguise/disguisetypes/Disguise.java | 8 +++++--- .../disguise/utilities/DisguiseUtilities.java | 15 ++++++++------- .../disguise/utilities/PacketsManager.java | 2 +- 4 files changed, 16 insertions(+), 12 deletions(-) diff --git a/src/me/libraryaddict/disguise/DisguiseAPI.java b/src/me/libraryaddict/disguise/DisguiseAPI.java index ee2aa3de..41860bf7 100644 --- a/src/me/libraryaddict/disguise/DisguiseAPI.java +++ b/src/me/libraryaddict/disguise/DisguiseAPI.java @@ -3,6 +3,7 @@ package me.libraryaddict.disguise; import java.lang.reflect.Field; import java.util.Arrays; import java.util.List; +import java.util.UUID; import me.libraryaddict.disguise.disguisetypes.Disguise; import me.libraryaddict.disguise.disguisetypes.TargetedDisguise; @@ -142,7 +143,7 @@ public class DisguiseAPI { /** * Get the ID of a fake disguise for a entityplayer */ - public static int getFakeDisguise(int entityId) { + public static int getFakeDisguise(UUID entityId) { if (DisguiseUtilities.getSelfDisguisesIds().containsKey(entityId)) return DisguiseUtilities.getSelfDisguisesIds().get(entityId); return -1; diff --git a/src/me/libraryaddict/disguise/disguisetypes/Disguise.java b/src/me/libraryaddict/disguise/disguisetypes/Disguise.java index 25b3ef13..36935ade 100644 --- a/src/me/libraryaddict/disguise/disguisetypes/Disguise.java +++ b/src/me/libraryaddict/disguise/disguisetypes/Disguise.java @@ -4,6 +4,7 @@ import java.lang.reflect.InvocationTargetException; import java.util.HashMap; import java.util.HashSet; import java.util.Iterator; +import java.util.UUID; import me.libraryaddict.disguise.DisguiseAPI; import me.libraryaddict.disguise.DisguiseConfig; @@ -33,6 +34,7 @@ public abstract class Disguise { private static JavaPlugin plugin; private DisguiseType disguiseType; private Entity entity; + private UUID disguiseUUID; private boolean hearSelfDisguise = DisguiseConfig.isSelfDisguisesSoundsReplaced(); private boolean hideArmorFromSelf = DisguiseConfig.isHidingArmorFromSelf(); private boolean hideHeldItemFromSelf = DisguiseConfig.isHidingHeldItemFromSelf(); @@ -229,7 +231,7 @@ public abstract class Disguise { (byte) Math.floor(loc.getPitch() * 256.0F / 360.0F))); if (isSelfDisguiseVisible() && getEntity() instanceof Player) { PacketContainer selfLookPacket = lookPacket.shallowClone(); - selfLookPacket.getModifier().write(0, DisguiseAPI.getFakeDisguise(getEntity().getEntityId())); + selfLookPacket.getModifier().write(0, DisguiseAPI.getFakeDisguise(getEntity().getUniqueId())); try { ProtocolLibrary.getProtocolManager().sendServerPacket((Player) getEntity(), selfLookPacket, false); @@ -248,7 +250,7 @@ public abstract class Disguise { if (!isSelfDisguiseVisible()) { continue; } - mods.write(0, DisguiseAPI.getFakeDisguise(getEntity().getEntityId())); + mods.write(0, DisguiseAPI.getFakeDisguise(getEntity().getUniqueId())); } else { mods.write(0, getEntity().getEntityId()); } @@ -274,7 +276,7 @@ public abstract class Disguise { ProtocolLibrary.getProtocolManager().sendServerPacket(player, packet, false); } else if (isSelfDisguiseVisible()) { PacketContainer selfPacket = packet.shallowClone(); - selfPacket.getModifier().write(0, DisguiseAPI.getFakeDisguise(getEntity().getEntityId())); + selfPacket.getModifier().write(0, DisguiseAPI.getFakeDisguise(getEntity().getUniqueId())); try { ProtocolLibrary.getProtocolManager().sendServerPacket((Player) getEntity(), selfPacket, false); diff --git a/src/me/libraryaddict/disguise/utilities/DisguiseUtilities.java b/src/me/libraryaddict/disguise/utilities/DisguiseUtilities.java index f3158f16..9ef2e9f5 100644 --- a/src/me/libraryaddict/disguise/utilities/DisguiseUtilities.java +++ b/src/me/libraryaddict/disguise/utilities/DisguiseUtilities.java @@ -8,6 +8,7 @@ import java.util.HashMap; import java.util.HashSet; import java.util.Iterator; import java.util.List; +import java.util.UUID; import me.libraryaddict.disguise.DisguiseAPI; import me.libraryaddict.disguise.LibsDisguises; @@ -39,7 +40,7 @@ public class DisguiseUtilities { private static LibsDisguises libsDisguises; // A internal storage of fake entity ID's I can use. // Realistically I could probably use a ID like "4" for everyone, seeing as no one shares the ID - private static HashMap selfDisguisesIds = new HashMap(); + private static HashMap selfDisguisesIds = new HashMap(); // Store the entity IDs instead of entitys because then I can disguise entitys even before they exist private static HashMap> targetedDisguises = new HashMap>(); @@ -247,7 +248,7 @@ public class DisguiseUtilities { return dis; } - public static HashMap getSelfDisguisesIds() { + public static HashMap getSelfDisguisesIds() { return selfDisguisesIds; } @@ -377,17 +378,17 @@ public class DisguiseUtilities { } public static void removeSelfDisguise(Player player) { - if (selfDisguisesIds.containsKey(player.getEntityId())) { + if (selfDisguisesIds.containsKey(player.getUniqueId())) { // Send a packet to destroy the fake entity PacketContainer packet = new PacketContainer(PacketType.Play.Server.ENTITY_DESTROY); - packet.getModifier().write(0, new int[] { selfDisguisesIds.get(player.getEntityId()) }); + packet.getModifier().write(0, new int[] { selfDisguisesIds.get(player.getUniqueId()) }); try { ProtocolLibrary.getProtocolManager().sendServerPacket(player, packet); } catch (Exception ex) { ex.printStackTrace(); } // Remove the fake entity ID from the disguise bin - selfDisguisesIds.remove(player.getEntityId()); + selfDisguisesIds.remove(player.getUniqueId()); // Get the entity tracker try { Object world = ReflectionManager.getWorld(player.getWorld()); @@ -444,7 +445,7 @@ public class DisguiseUtilities { }); return; } - int fakeId = selfDisguisesIds.get(player.getEntityId()); + int fakeId = selfDisguisesIds.get(player.getUniqueId()); // Add himself to his own entity tracker ((HashSet) entityTrackerEntry.getClass().getField("trackedPlayers").get(entityTrackerEntry)).add(ReflectionManager .getNmsEntity(player)); @@ -572,7 +573,7 @@ public class DisguiseUtilities { int id = field.getInt(null); // Set the entitycount plus one so we don't have the id being reused field.set(null, id + 1); - selfDisguisesIds.put(player.getEntityId(), id); + selfDisguisesIds.put(player.getUniqueId(), id); } catch (Exception ex) { ex.printStackTrace(); } diff --git a/src/me/libraryaddict/disguise/utilities/PacketsManager.java b/src/me/libraryaddict/disguise/utilities/PacketsManager.java index 2f694964..2714369d 100644 --- a/src/me/libraryaddict/disguise/utilities/PacketsManager.java +++ b/src/me/libraryaddict/disguise/utilities/PacketsManager.java @@ -707,7 +707,7 @@ public class PacketsManager { public void onPacketSending(PacketEvent event) { final Player observer = event.getPlayer(); if (event.getPacket().getIntegers().read(0) == observer.getEntityId()) { - int fakeId = DisguiseAPI.getFakeDisguise(observer.getEntityId()); + int fakeId = DisguiseAPI.getFakeDisguise(observer.getUniqueId()); if (fakeId > 0) { // Here I grab the packets to convert them to, So I can display them as if the disguise sent them. PacketContainer[] packets = transformPacket(event.getPacket(), observer, observer); From 07bf03f15481906c39c616c56e06e8826d213b90 Mon Sep 17 00:00:00 2001 From: libraryaddict Date: Thu, 3 Apr 2014 01:54:36 +1300 Subject: [PATCH 2/7] Change the disguises to store UUID's. Not ints. --- .../libraryaddict/disguise/DisguiseAPI.java | 8 +++---- .../disguise/disguisetypes/Disguise.java | 7 +++--- .../disguise/utilities/DisguiseUtilities.java | 24 +++++++++---------- 3 files changed, 19 insertions(+), 20 deletions(-) diff --git a/src/me/libraryaddict/disguise/DisguiseAPI.java b/src/me/libraryaddict/disguise/DisguiseAPI.java index 41860bf7..46f1dcf0 100644 --- a/src/me/libraryaddict/disguise/DisguiseAPI.java +++ b/src/me/libraryaddict/disguise/DisguiseAPI.java @@ -43,7 +43,7 @@ public class DisguiseAPI { disguise.setEntity(entity); } // Stick the disguise in the disguises bin - DisguiseUtilities.addDisguise(entity.getEntityId(), (TargetedDisguise) disguise); + DisguiseUtilities.addDisguise(entity.getUniqueId(), (TargetedDisguise) disguise); // Resend the disguised entity's packet DisguiseUtilities.refreshTrackers((TargetedDisguise) disguise); // If he is a player, then self disguise himself @@ -119,7 +119,7 @@ public class DisguiseAPI { public static Disguise getDisguise(Entity disguised) { if (disguised == null) return null; - return DisguiseUtilities.getMainDisguise(disguised.getEntityId()); + return DisguiseUtilities.getMainDisguise(disguised.getUniqueId()); } /** @@ -128,7 +128,7 @@ public class DisguiseAPI { public static Disguise getDisguise(Player observer, Entity disguised) { if (disguised == null || observer == null) return null; - return DisguiseUtilities.getDisguise(observer, disguised.getEntityId()); + return DisguiseUtilities.getDisguise(observer, disguised.getUniqueId()); } /** @@ -137,7 +137,7 @@ public class DisguiseAPI { public static Disguise[] getDisguises(Entity disguised) { if (disguised == null) return null; - return DisguiseUtilities.getDisguises(disguised.getEntityId()); + return DisguiseUtilities.getDisguises(disguised.getUniqueId()); } /** diff --git a/src/me/libraryaddict/disguise/disguisetypes/Disguise.java b/src/me/libraryaddict/disguise/disguisetypes/Disguise.java index 36935ade..e9822304 100644 --- a/src/me/libraryaddict/disguise/disguisetypes/Disguise.java +++ b/src/me/libraryaddict/disguise/disguisetypes/Disguise.java @@ -34,7 +34,6 @@ public abstract class Disguise { private static JavaPlugin plugin; private DisguiseType disguiseType; private Entity entity; - private UUID disguiseUUID; private boolean hearSelfDisguise = DisguiseConfig.isSelfDisguisesSoundsReplaced(); private boolean hideArmorFromSelf = DisguiseConfig.isHidingArmorFromSelf(); private boolean hideHeldItemFromSelf = DisguiseConfig.isHidingHeldItemFromSelf(); @@ -375,7 +374,7 @@ public abstract class Disguise { velocityRunnable.cancel(); } catch (Exception ex) { } - HashMap> disguises = DisguiseUtilities.getDisguises(); + HashMap> disguises = DisguiseUtilities.getDisguises(); // If this disguise has a entity set if (getEntity() != null) { // If this disguise is active @@ -393,9 +392,9 @@ public abstract class Disguise { } } else { // Loop through the disguises because it could be used with a unknown entity id. - Iterator itel = disguises.keySet().iterator(); + Iterator itel = disguises.keySet().iterator(); while (itel.hasNext()) { - int id = itel.next(); + UUID id = itel.next(); if (disguises.get(id).remove(this) && disguises.get(id).isEmpty()) { itel.remove(); } diff --git a/src/me/libraryaddict/disguise/utilities/DisguiseUtilities.java b/src/me/libraryaddict/disguise/utilities/DisguiseUtilities.java index 9ef2e9f5..f684666d 100644 --- a/src/me/libraryaddict/disguise/utilities/DisguiseUtilities.java +++ b/src/me/libraryaddict/disguise/utilities/DisguiseUtilities.java @@ -42,9 +42,9 @@ public class DisguiseUtilities { // Realistically I could probably use a ID like "4" for everyone, seeing as no one shares the ID private static HashMap selfDisguisesIds = new HashMap(); // Store the entity IDs instead of entitys because then I can disguise entitys even before they exist - private static HashMap> targetedDisguises = new HashMap>(); + private static HashMap> targetedDisguises = new HashMap>(); - public static void addDisguise(int entityId, TargetedDisguise disguise) { + public static void addDisguise(UUID entityId, TargetedDisguise disguise) { if (!getDisguises().containsKey(entityId)) { getDisguises().put(entityId, new HashSet()); } @@ -62,7 +62,7 @@ public class DisguiseUtilities { public static void checkConflicts(TargetedDisguise disguise, String name) { // If the disguise is being used.. Else we may accidentally undisguise something else if (DisguiseAPI.isDisguiseInUse(disguise)) { - Iterator disguiseItel = getDisguises().get(disguise.getEntity().getEntityId()).iterator(); + Iterator disguiseItel = getDisguises().get(disguise.getEntity().getUniqueId()).iterator(); // Iterate through the disguises while (disguiseItel.hasNext()) { TargetedDisguise d = disguiseItel.next(); @@ -163,7 +163,7 @@ public class DisguiseUtilities { } } - public static TargetedDisguise getDisguise(Player observer, int entityId) { + public static TargetedDisguise getDisguise(Player observer, UUID entityId) { if (getDisguises().containsKey(entityId)) { for (TargetedDisguise disguise : getDisguises().get(entityId)) { if (disguise.canSee(observer)) { @@ -174,18 +174,18 @@ public class DisguiseUtilities { return null; } - public static HashMap> getDisguises() { + public static HashMap> getDisguises() { return targetedDisguises; } - public static TargetedDisguise[] getDisguises(int entityId) { + public static TargetedDisguise[] getDisguises(UUID entityId) { if (getDisguises().containsKey(entityId)) { return getDisguises().get(entityId).toArray(new TargetedDisguise[getDisguises().get(entityId).size()]); } return new TargetedDisguise[0]; } - public static TargetedDisguise getMainDisguise(int entityId) { + public static TargetedDisguise getMainDisguise(UUID entityId) { TargetedDisguise toReturn = null; if (getDisguises().containsKey(entityId)) { for (TargetedDisguise disguise : getDisguises().get(entityId)) { @@ -257,8 +257,8 @@ public class DisguiseUtilities { } public static boolean isDisguiseInUse(Disguise disguise) { - if (disguise.getEntity() != null && getDisguises().containsKey(disguise.getEntity().getEntityId()) - && getDisguises().get(disguise.getEntity().getEntityId()).contains(disguise)) { + if (disguise.getEntity() != null && getDisguises().containsKey(disguise.getEntity().getUniqueId()) + && getDisguises().get(disguise.getEntity().getUniqueId()).contains(disguise)) { return true; } return false; @@ -364,7 +364,7 @@ public class DisguiseUtilities { } public static boolean removeDisguise(TargetedDisguise disguise) { - int entityId = disguise.getEntity().getEntityId(); + UUID entityId = disguise.getEntity().getUniqueId(); if (getDisguises().containsKey(entityId) && getDisguises().get(entityId).remove(disguise)) { if (getDisguises().get(entityId).isEmpty()) { getDisguises().remove(entityId); @@ -551,8 +551,8 @@ public class DisguiseUtilities { public static void setupFakeDisguise(final Disguise disguise) { Entity e = disguise.getEntity(); // If the disguises entity is null, or the disguised entity isn't a player return - if (e == null || !(e instanceof Player) || !getDisguises().containsKey(e.getEntityId()) - || !getDisguises().get(e.getEntityId()).contains(disguise)) { + if (e == null || !(e instanceof Player) || !getDisguises().containsKey(e.getUniqueId()) + || !getDisguises().get(e.getUniqueId()).contains(disguise)) { return; } Player player = (Player) e; From 167f14bfe87dd3ee4c8d0f8e705342563e358a73 Mon Sep 17 00:00:00 2001 From: libraryaddict Date: Thu, 3 Apr 2014 02:02:58 +1300 Subject: [PATCH 3/7] Add support for disguiseNextEntity --- src/me/libraryaddict/disguise/DisguiseAPI.java | 4 ++-- .../disguise/utilities/DisguiseUtilities.java | 16 +++++++++++++++- 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/src/me/libraryaddict/disguise/DisguiseAPI.java b/src/me/libraryaddict/disguise/DisguiseAPI.java index 46f1dcf0..0ab7fe8c 100644 --- a/src/me/libraryaddict/disguise/DisguiseAPI.java +++ b/src/me/libraryaddict/disguise/DisguiseAPI.java @@ -78,7 +78,7 @@ public class DisguiseAPI { Field field = ReflectionManager.getNmsClass("Entity").getDeclaredField("entityCount"); field.setAccessible(true); int id = field.getInt(null); - DisguiseUtilities.addDisguise(id, (TargetedDisguise) disguise); + DisguiseUtilities.addFutureDisguise(id, (TargetedDisguise) disguise); } catch (Exception ex) { ex.printStackTrace(); } @@ -128,7 +128,7 @@ public class DisguiseAPI { public static Disguise getDisguise(Player observer, Entity disguised) { if (disguised == null || observer == null) return null; - return DisguiseUtilities.getDisguise(observer, disguised.getUniqueId()); + return DisguiseUtilities.getDisguise(observer, disguised); } /** diff --git a/src/me/libraryaddict/disguise/utilities/DisguiseUtilities.java b/src/me/libraryaddict/disguise/utilities/DisguiseUtilities.java index f684666d..9f3c9751 100644 --- a/src/me/libraryaddict/disguise/utilities/DisguiseUtilities.java +++ b/src/me/libraryaddict/disguise/utilities/DisguiseUtilities.java @@ -43,6 +43,14 @@ public class DisguiseUtilities { private static HashMap selfDisguisesIds = new HashMap(); // Store the entity IDs instead of entitys because then I can disguise entitys even before they exist private static HashMap> targetedDisguises = new HashMap>(); + private static HashMap> futureDisguises = new HashMap>(); + + public static void addFutureDisguise(int entityId, TargetedDisguise disguise) { + if (!futureDisguises.containsKey(entityId)) { + futureDisguises.put(entityId, new HashSet()); + } + futureDisguises.get(entityId).add(disguise); + } public static void addDisguise(UUID entityId, TargetedDisguise disguise) { if (!getDisguises().containsKey(entityId)) { @@ -163,7 +171,13 @@ public class DisguiseUtilities { } } - public static TargetedDisguise getDisguise(Player observer, UUID entityId) { + public static TargetedDisguise getDisguise(Player observer, Entity entity) { + UUID entityId = entity.getUniqueId(); + if (futureDisguises.containsKey(entity.getEntityId())) { + for (TargetedDisguise disguise : futureDisguises.remove(entity.getEntityId())) { + addDisguise(entityId, disguise); + } + } if (getDisguises().containsKey(entityId)) { for (TargetedDisguise disguise : getDisguises().get(entityId)) { if (disguise.canSee(observer)) { From 376f18ef95cf0afc5e5e81b35554bf77f0290bb0 Mon Sep 17 00:00:00 2001 From: libraryaddict Date: Thu, 3 Apr 2014 02:06:21 +1300 Subject: [PATCH 4/7] Maybe something so the disguise can be reused if the entity comes back --- src/me/libraryaddict/disguise/disguisetypes/Disguise.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/me/libraryaddict/disguise/disguisetypes/Disguise.java b/src/me/libraryaddict/disguise/disguisetypes/Disguise.java index e9822304..95bf4037 100644 --- a/src/me/libraryaddict/disguise/disguisetypes/Disguise.java +++ b/src/me/libraryaddict/disguise/disguisetypes/Disguise.java @@ -188,6 +188,10 @@ public abstract class Disguise { if (!getEntity().isValid()) { if (isRemoveWhenInvalid()) { removeDisguise(); + } else { + entity = null; + watcher = getWatcher().clone(disguise); + cancel(); } } else { // If the disguise type is tnt, we need to resend the entity packet else it will turn invisible From 25df368e9a916c3e2c06198371734e2c4a1a38ec Mon Sep 17 00:00:00 2001 From: libraryaddict Date: Thu, 3 Apr 2014 02:39:52 +1300 Subject: [PATCH 5/7] Added new config options to keep a disguise --- config.yml | 10 +++- .../disguise/DisguiseConfig.java | 27 ++++++++++ .../libraryaddict/disguise/LibsDisguises.java | 3 ++ .../disguise/disguisetypes/Disguise.java | 50 ++++++++++++++----- .../disguise/utilities/DisguiseUtilities.java | 16 +++--- 5 files changed, 84 insertions(+), 22 deletions(-) diff --git a/config.yml b/config.yml index 5e30ee11..7c6fa2e8 100644 --- a/config.yml +++ b/config.yml @@ -55,4 +55,12 @@ MonstersIgnoreDisguises: false # Works only for disguised players when attacked by a entity (arrow, monster. etc) # This will blow all disguises he has on him BlowDisguises: false -BlownDisguiseMessage: '&cYour disguise was blown!' \ No newline at end of file +BlownDisguiseMessage: '&cYour disguise was blown!' + +# This I don't really recommend turning on as it can make a memory leak.. +# These disguises, as normal will not persist after a server restart. +# There is also no EntityDeath option as entities do not revive after death. +KeepDisguises: + PlayerDeath: false + PlayerLogout: false + EntityDespawn: false \ No newline at end of file diff --git a/src/me/libraryaddict/disguise/DisguiseConfig.java b/src/me/libraryaddict/disguise/DisguiseConfig.java index a3b8858c..819f6ed4 100644 --- a/src/me/libraryaddict/disguise/DisguiseConfig.java +++ b/src/me/libraryaddict/disguise/DisguiseConfig.java @@ -9,6 +9,9 @@ public class DisguiseConfig { private static boolean hearSelfDisguise; private static boolean hidingArmor; private static boolean hidingHeldItem; + private static boolean keepDisguiseEntityDespawn; + private static boolean keepDisguisePlayerDeath; + private static boolean keepDisguisePlayerLogout; private static boolean modifyBoundingBox; private static boolean removeUnseenDisguises; private static boolean sendVelocity; @@ -47,6 +50,18 @@ public class DisguiseConfig { return hidingHeldItem; } + public static boolean isKeepDisguiseOnEntityDespawn() { + return keepDisguiseEntityDespawn; + } + + public static boolean isKeepDisguiseOnPlayerDeath() { + return keepDisguisePlayerDeath; + } + + public static boolean isKeepDisguiseOnPlayerLogout() { + return keepDisguisePlayerLogout; + } + public static boolean isModifyBoundingBox() { return modifyBoundingBox; } @@ -133,6 +148,18 @@ public class DisguiseConfig { } } + public static void setKeepDisguiseOnEntityDespawn(boolean keepDisguise) { + keepDisguiseEntityDespawn = keepDisguise; + } + + public static void setKeepDisguiseOnPlayerDeath(boolean keepDisguise) { + keepDisguisePlayerDeath = keepDisguise; + } + + public static void setKeepDisguiseOnPlayerLogout(boolean keepDisguise) { + keepDisguisePlayerLogout = keepDisguise; + } + public static void setModifyBoundingBox(boolean modifyBounding) { modifyBoundingBox = modifyBounding; } diff --git a/src/me/libraryaddict/disguise/LibsDisguises.java b/src/me/libraryaddict/disguise/LibsDisguises.java index ab318167..e0867d61 100644 --- a/src/me/libraryaddict/disguise/LibsDisguises.java +++ b/src/me/libraryaddict/disguise/LibsDisguises.java @@ -74,6 +74,9 @@ public class LibsDisguises extends JavaPlugin { DisguiseConfig.setDisguiseBlownOnAttack(getConfig().getBoolean("BlowDisguises")); DisguiseConfig.setDisguiseBlownMessage(ChatColor.translateAlternateColorCodes('&', getConfig().getString("BlownDisguiseMessage"))); + DisguiseConfig.setKeepDisguiseOnPlayerDeath(getConfig().getBoolean("KeepDisguises.PlayerDeath")); + DisguiseConfig.setKeepDisguiseOnPlayerLogout(getConfig().getBoolean("KeepDisguises.PlayerLogout")); + DisguiseConfig.setKeepDisguiseOnEntityDespawn(getConfig().getBoolean("KeepDisguises.EntityDespawn")); try { // Here I use reflection to set the plugin for Disguise.. // Kind of stupid but I don't want open API calls for a commonly used object. diff --git a/src/me/libraryaddict/disguise/disguisetypes/Disguise.java b/src/me/libraryaddict/disguise/disguisetypes/Disguise.java index 95bf4037..b407a7e7 100644 --- a/src/me/libraryaddict/disguise/disguisetypes/Disguise.java +++ b/src/me/libraryaddict/disguise/disguisetypes/Disguise.java @@ -17,6 +17,7 @@ import me.libraryaddict.disguise.utilities.PacketsManager; import me.libraryaddict.disguise.utilities.ReflectionManager; import me.libraryaddict.disguise.utilities.DisguiseValues; +import org.bukkit.Bukkit; import org.bukkit.Location; import org.bukkit.entity.Entity; import org.bukkit.entity.Horse.Variant; @@ -37,8 +38,10 @@ public abstract class Disguise { private boolean hearSelfDisguise = DisguiseConfig.isSelfDisguisesSoundsReplaced(); private boolean hideArmorFromSelf = DisguiseConfig.isHidingArmorFromSelf(); private boolean hideHeldItemFromSelf = DisguiseConfig.isHidingHeldItemFromSelf(); + private boolean keepDisguiseEntityDespawn = DisguiseConfig.isKeepDisguiseOnEntityDespawn(); + private boolean keepDisguisePlayerDeath = DisguiseConfig.isKeepDisguiseOnPlayerDeath(); + private boolean keepDisguisePlayerLogout = DisguiseConfig.isKeepDisguiseOnPlayerLogout(); private boolean modifyBoundingBox = DisguiseConfig.isModifyBoundingBox(); - private boolean removeWhenInvalid = true; private boolean replaceSounds = DisguiseConfig.isSoundEnabled(); private BukkitRunnable velocityRunnable; private boolean velocitySent = DisguiseConfig.isVelocitySent(); @@ -186,7 +189,15 @@ public abstract class Disguise { public void run() { // If entity is no longer valid. Remove it. if (!getEntity().isValid()) { - if (isRemoveWhenInvalid()) { + + if (getEntity() instanceof Player ? + + (Bukkit.getPlayerExact(((Player) getEntity()).getName()) == null ? !isKeepDisguiseOnPlayerLogout() + : !isKeepDisguiseOnPlayerDeath()) + + : + + (!isKeepDisguiseOnEntityDespawn() || getEntity().isDead())) { removeDisguise(); } else { entity = null; @@ -327,6 +338,18 @@ public abstract class Disguise { return hideHeldItemFromSelf; } + public boolean isKeepDisguiseOnEntityDespawn() { + return this.keepDisguiseEntityDespawn; + } + + public boolean isKeepDisguiseOnPlayerDeath() { + return this.keepDisguisePlayerDeath; + } + + public boolean isKeepDisguiseOnPlayerLogout() { + return this.keepDisguisePlayerLogout; + } + public boolean isMiscDisguise() { return false; } @@ -343,13 +366,6 @@ public abstract class Disguise { return false; } - /** - * Is the disguise removed when the disguised entity is invalid? - */ - public boolean isRemoveWhenInvalid() { - return removeWhenInvalid; - } - public boolean isSelfDisguiseSoundsReplaced() { return hearSelfDisguise; } @@ -443,6 +459,18 @@ public abstract class Disguise { } } + public void setKeepDisguiseOnEntityDespawn(boolean keepDisguise) { + this.keepDisguiseEntityDespawn = keepDisguise; + } + + public void setKeepDisguiseOnPlayerDeath(boolean keepDisguise) { + this.keepDisguisePlayerDeath = keepDisguise; + } + + public void setKeepDisguiseOnPlayerLogout(boolean keepDisguise) { + this.keepDisguisePlayerLogout = keepDisguise; + } + public void setModifyBoundingBox(boolean modifyBox) { if (((TargetedDisguise) this).getDisguiseTarget() != TargetType.SHOW_TO_EVERYONE_BUT_THESE_PLAYERS) { throw new RuntimeException( @@ -456,10 +484,6 @@ public abstract class Disguise { } } - public void setRemoveDisguiseWhenInvalid(boolean removeWhenInvalid) { - this.removeWhenInvalid = removeWhenInvalid; - } - public void setReplaceSounds(boolean areSoundsReplaced) { replaceSounds = areSoundsReplaced; } diff --git a/src/me/libraryaddict/disguise/utilities/DisguiseUtilities.java b/src/me/libraryaddict/disguise/utilities/DisguiseUtilities.java index 9f3c9751..b97be734 100644 --- a/src/me/libraryaddict/disguise/utilities/DisguiseUtilities.java +++ b/src/me/libraryaddict/disguise/utilities/DisguiseUtilities.java @@ -37,20 +37,13 @@ import com.comphenix.protocol.events.PacketContainer; import com.comphenix.protocol.wrappers.WrappedDataWatcher; public class DisguiseUtilities { + private static HashMap> futureDisguises = new HashMap>(); private static LibsDisguises libsDisguises; // A internal storage of fake entity ID's I can use. // Realistically I could probably use a ID like "4" for everyone, seeing as no one shares the ID private static HashMap selfDisguisesIds = new HashMap(); // Store the entity IDs instead of entitys because then I can disguise entitys even before they exist private static HashMap> targetedDisguises = new HashMap>(); - private static HashMap> futureDisguises = new HashMap>(); - - public static void addFutureDisguise(int entityId, TargetedDisguise disguise) { - if (!futureDisguises.containsKey(entityId)) { - futureDisguises.put(entityId, new HashSet()); - } - futureDisguises.get(entityId).add(disguise); - } public static void addDisguise(UUID entityId, TargetedDisguise disguise) { if (!getDisguises().containsKey(entityId)) { @@ -63,6 +56,13 @@ public class DisguiseUtilities { } } + public static void addFutureDisguise(int entityId, TargetedDisguise disguise) { + if (!futureDisguises.containsKey(entityId)) { + futureDisguises.put(entityId, new HashSet()); + } + futureDisguises.get(entityId).add(disguise); + } + /** * If name isn't null. Make sure that the name doesn't see any other disguise. Else if name is null. Make sure that the * observers in the disguise don't see any other disguise. From 8c20f0c3b606354bef9abfdf8b7b84c03a578037 Mon Sep 17 00:00:00 2001 From: libraryaddict Date: Thu, 3 Apr 2014 02:40:19 +1300 Subject: [PATCH 6/7] Changed default value of 'RemoveHeldItem' to false as its annoying --- config.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config.yml b/config.yml index 7c6fa2e8..863bd1ca 100644 --- a/config.yml +++ b/config.yml @@ -23,7 +23,7 @@ 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 +RemoveHeldItem: false # 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. From 8f63a6eaa0205a9a00d3bced69661c40fe40824b Mon Sep 17 00:00:00 2001 From: libraryaddict Date: Thu, 3 Apr 2014 02:49:33 +1300 Subject: [PATCH 7/7] Removed Deprecated methods and added a few isAdult codes to zombie and ageable watchers --- .../disguise/DisguiseConfig.java | 5 --- .../disguise/disguisetypes/Disguise.java | 19 ++-------- .../disguise/disguisetypes/FlagWatcher.java | 21 ----------- .../disguise/disguisetypes/MiscDisguise.java | 2 +- .../disguise/disguisetypes/MobDisguise.java | 4 +-- .../watchers/AgeableWatcher.java | 10 +++--- .../watchers/CreeperWatcher.java | 17 --------- .../watchers/EndermanWatcher.java | 36 ------------------- .../disguisetypes/watchers/GhastWatcher.java | 11 ------ .../disguisetypes/watchers/HorseWatcher.java | 24 +------------ .../disguisetypes/watchers/LivingWatcher.java | 9 ----- .../disguisetypes/watchers/OcelotWatcher.java | 6 ---- .../watchers/PaintingWatcher.java | 5 --- .../watchers/VillagerWatcher.java | 14 ++------ .../disguisetypes/watchers/ZombieWatcher.java | 12 ++++--- .../utilities/BaseDisguiseCommand.java | 28 --------------- 16 files changed, 21 insertions(+), 202 deletions(-) diff --git a/src/me/libraryaddict/disguise/DisguiseConfig.java b/src/me/libraryaddict/disguise/DisguiseConfig.java index 819f6ed4..7f07306b 100644 --- a/src/me/libraryaddict/disguise/DisguiseConfig.java +++ b/src/me/libraryaddict/disguise/DisguiseConfig.java @@ -19,11 +19,6 @@ public class DisguiseConfig { private static boolean showNameAboveHeadAlwaysVisible; private static boolean targetDisguises; - @Deprecated - public static boolean canHearSelfDisguise() { - return hearSelfDisguise; - } - public static String getDisguiseBlownMessage() { return disguiseBlownMessage; } diff --git a/src/me/libraryaddict/disguise/disguisetypes/Disguise.java b/src/me/libraryaddict/disguise/disguisetypes/Disguise.java index b407a7e7..9bc8a072 100644 --- a/src/me/libraryaddict/disguise/disguisetypes/Disguise.java +++ b/src/me/libraryaddict/disguise/disguisetypes/Disguise.java @@ -48,11 +48,6 @@ public abstract class Disguise { private boolean viewSelfDisguise = DisguiseConfig.isViewDisguises(); private FlagWatcher watcher; - @Deprecated - public boolean canHearSelfDisguise() { - return hearSelfDisguise; - } - @Override public abstract Disguise clone(); @@ -86,9 +81,9 @@ public abstract class Disguise { // Set the disguise if its a baby or not if (!isAdult) { if (getWatcher() instanceof AgeableWatcher) { - ((AgeableWatcher) getWatcher()).setAdult(false); + ((AgeableWatcher) getWatcher()).setBaby(true); } else if (getWatcher() instanceof ZombieWatcher) { - ((ZombieWatcher) getWatcher()).setAdult(false); + ((ZombieWatcher) getWatcher()).setBaby(true); } } // If the disguise type is a wither, set the flagwatcher value for the skeleton to a wither skeleton @@ -422,11 +417,6 @@ public abstract class Disguise { } } - @Deprecated - public boolean replaceSounds() { - return replaceSounds; - } - /** * Set the entity of the disguise. Only used for internal things. */ @@ -614,9 +604,4 @@ public abstract class Disguise { public void setWatcher(FlagWatcher newWatcher) { watcher = newWatcher; } - - @Deprecated - public boolean viewSelfDisguise() { - return viewSelfDisguise; - } } \ No newline at end of file diff --git a/src/me/libraryaddict/disguise/disguisetypes/FlagWatcher.java b/src/me/libraryaddict/disguise/disguisetypes/FlagWatcher.java index a744b0a0..6455983e 100644 --- a/src/me/libraryaddict/disguise/disguisetypes/FlagWatcher.java +++ b/src/me/libraryaddict/disguise/disguisetypes/FlagWatcher.java @@ -161,11 +161,6 @@ public class FlagWatcher { return ((Byte) getValue(0, (byte) 0) & 1 << byteValue) != 0; } - @Deprecated - public ItemStack getHeldItem() { - return getItemInHand(); - } - public ItemStack getItemInHand() { return getItemStack(SlotType.HELD_ITEM); } @@ -200,11 +195,6 @@ public class FlagWatcher { return getFlag(5); } - @Deprecated - public boolean isRiding() { - return getFlag(2); - } - public boolean isRightClicking() { return getFlag(4); } @@ -269,11 +259,6 @@ public class FlagWatcher { } } - @Deprecated - public void setHeldItem(ItemStack itemstack) { - setItemInHand(itemstack); - } - public void setInvisible(boolean setInvis) { setFlag(5, setInvis); sendData(0); @@ -328,12 +313,6 @@ public class FlagWatcher { setItemStack(slot.getSlot(), itemStack); } - @Deprecated - public void setRiding(boolean setRiding) { - setFlag(2, setRiding); - sendData(0); - } - public void setRightClicking(boolean setRightClicking) { setFlag(4, setRightClicking); sendData(0); diff --git a/src/me/libraryaddict/disguise/disguisetypes/MiscDisguise.java b/src/me/libraryaddict/disguise/disguisetypes/MiscDisguise.java index 26461f6f..98f0970b 100644 --- a/src/me/libraryaddict/disguise/disguisetypes/MiscDisguise.java +++ b/src/me/libraryaddict/disguise/disguisetypes/MiscDisguise.java @@ -69,7 +69,7 @@ public class MiscDisguise extends TargetedDisguise { ((FallingBlockWatcher) getWatcher()).setBlock(new ItemStack(this.id, 1, (short) this.data)); break; case PAINTING: - ((PaintingWatcher) getWatcher()).setArtId(this.data); + ((PaintingWatcher) getWatcher()).setArt(Art.values()[this.data % Art.values().length]); break; case SPLASH_POTION: ((SplashPotionWatcher) getWatcher()).setPotionId(this.data); diff --git a/src/me/libraryaddict/disguise/disguisetypes/MobDisguise.java b/src/me/libraryaddict/disguise/disguisetypes/MobDisguise.java index 5fbc98dd..4e532c06 100644 --- a/src/me/libraryaddict/disguise/disguisetypes/MobDisguise.java +++ b/src/me/libraryaddict/disguise/disguisetypes/MobDisguise.java @@ -62,9 +62,9 @@ public class MobDisguise extends TargetedDisguise { public boolean isAdult() { if (getWatcher() != null) { if (getWatcher() instanceof AgeableWatcher) - return ((AgeableWatcher) getWatcher()).isAdult(); + return ((AgeableWatcher) getWatcher()).isBaby(); else if (getWatcher() instanceof ZombieWatcher) - return ((ZombieWatcher) getWatcher()).isAdult(); + return ((ZombieWatcher) getWatcher()).isBaby(); return false; } return isAdult; diff --git a/src/me/libraryaddict/disguise/disguisetypes/watchers/AgeableWatcher.java b/src/me/libraryaddict/disguise/disguisetypes/watchers/AgeableWatcher.java index ad320608..fcc24855 100644 --- a/src/me/libraryaddict/disguise/disguisetypes/watchers/AgeableWatcher.java +++ b/src/me/libraryaddict/disguise/disguisetypes/watchers/AgeableWatcher.java @@ -12,7 +12,6 @@ public class AgeableWatcher extends LivingWatcher { return (Integer) getValue(12, 0); } - @Deprecated public boolean isAdult() { return !isBaby(); } @@ -21,9 +20,8 @@ public class AgeableWatcher extends LivingWatcher { return (Integer) getValue(12, 0) < 0; } - @Deprecated - public void setAdult(boolean isAdult) { - setBaby(!isAdult); + public void setAdult() { + setBaby(false); } public void setAge(int newAge) { @@ -31,6 +29,10 @@ public class AgeableWatcher extends LivingWatcher { sendData(12); } + public void setBaby() { + setBaby(true); + } + public void setBaby(boolean isBaby) { setValue(12, isBaby ? -24000 : 0); sendData(12); diff --git a/src/me/libraryaddict/disguise/disguisetypes/watchers/CreeperWatcher.java b/src/me/libraryaddict/disguise/disguisetypes/watchers/CreeperWatcher.java index 71ad3c85..1f6dda31 100644 --- a/src/me/libraryaddict/disguise/disguisetypes/watchers/CreeperWatcher.java +++ b/src/me/libraryaddict/disguise/disguisetypes/watchers/CreeperWatcher.java @@ -8,11 +8,6 @@ public class CreeperWatcher extends LivingWatcher { super(disguise); } - @Deprecated - public boolean isFused() { - return (Byte) getValue(16, (byte) 0) == 1; - } - public boolean isIgnited() { return (Byte) getValue(18, (byte) 0) == 1; } @@ -21,18 +16,6 @@ public class CreeperWatcher extends LivingWatcher { return (Byte) getValue(17, (byte) 0) == 1; } - @Deprecated - public void setFuse(boolean isFused) { - setValue(16, (byte) (isFused ? 1 : -1)); - sendData(16); - } - - @Deprecated - public void setFused(boolean isFused) { - setValue(16, (byte) (isFused ? 1 : -1)); - sendData(16); - } - public void setIgnited(boolean ignited) { setValue(18, (byte) (ignited ? 1 : 0)); sendData(18); diff --git a/src/me/libraryaddict/disguise/disguisetypes/watchers/EndermanWatcher.java b/src/me/libraryaddict/disguise/disguisetypes/watchers/EndermanWatcher.java index c7c60659..dcccd618 100644 --- a/src/me/libraryaddict/disguise/disguisetypes/watchers/EndermanWatcher.java +++ b/src/me/libraryaddict/disguise/disguisetypes/watchers/EndermanWatcher.java @@ -10,22 +10,6 @@ public class EndermanWatcher extends LivingWatcher { super(disguise); } - @Deprecated - public int getCarriedData() { - return ((Byte) getValue(17, (byte) 0)); - } - - @Deprecated - public int getCarriedId() { - return ((Byte) getValue(16, (byte) 0)); - } - - @Override - @Deprecated - public ItemStack getHeldItem() { - return getItemInHand(); - } - @Override public ItemStack getItemInHand() { return new ItemStack((Byte) getValue(16, (byte) 0), 1, ((Byte) getValue(17, (byte) 0))); @@ -40,26 +24,6 @@ public class EndermanWatcher extends LivingWatcher { sendData(18); } - @Deprecated - public void setCarriedItem(int id, int dataValue) { - setValue(16, (byte) (id & 255)); - setValue(17, (byte) (dataValue & 255)); - sendData(16); - sendData(17); - } - - @Deprecated - public void setCarriedItem(ItemStack itemstack) { - setValue(16, (byte) (itemstack.getTypeId() & 255)); - setValue(17, (byte) (itemstack.getDurability() & 255)); - } - - @Override - @Deprecated - public void setHeldItem(ItemStack itemstack) { - setItemInHand(itemstack); - } - @Override public void setItemInHand(ItemStack itemstack) { setValue(16, (byte) (itemstack.getTypeId() & 255)); diff --git a/src/me/libraryaddict/disguise/disguisetypes/watchers/GhastWatcher.java b/src/me/libraryaddict/disguise/disguisetypes/watchers/GhastWatcher.java index b17bdb93..5d11ba9d 100644 --- a/src/me/libraryaddict/disguise/disguisetypes/watchers/GhastWatcher.java +++ b/src/me/libraryaddict/disguise/disguisetypes/watchers/GhastWatcher.java @@ -12,20 +12,9 @@ public class GhastWatcher extends LivingWatcher { return (Byte) getValue(16, (byte) 0) == 1; } - @Deprecated - public boolean isAgressive() { - return (Byte) getValue(16, (byte) 0) == 1; - } - public void setAggressive(boolean isAgressive) { setValue(16, (byte) (isAgressive ? 1 : 0)); sendData(16); } - @Deprecated - public void setAgressive(boolean isAgressive) { - setValue(16, (byte) (isAgressive ? 1 : 0)); - sendData(16); - } - } diff --git a/src/me/libraryaddict/disguise/disguisetypes/watchers/HorseWatcher.java b/src/me/libraryaddict/disguise/disguisetypes/watchers/HorseWatcher.java index 8ddf8263..8d766dd8 100644 --- a/src/me/libraryaddict/disguise/disguisetypes/watchers/HorseWatcher.java +++ b/src/me/libraryaddict/disguise/disguisetypes/watchers/HorseWatcher.java @@ -11,7 +11,7 @@ public class HorseWatcher extends AgeableWatcher { public HorseWatcher(Disguise disguise) { super(disguise); - setColorId(new Random().nextInt(Color.values().length)); + setColor(Color.values()[new Random().nextInt(Color.values().length)]); } public Color getColor() { @@ -34,11 +34,6 @@ public class HorseWatcher extends AgeableWatcher { return isTrue(8); } - @Deprecated - public boolean isBredable() { - return isTrue(16); - } - public boolean isBreedable() { return isTrue(16); } @@ -67,11 +62,6 @@ public class HorseWatcher extends AgeableWatcher { return ((Integer) getValue(16, (byte) 0) & i) != 0; } - @Deprecated - public void setCanBred(boolean breed) { - setFlag(16, breed); - } - public void setCanBreed(boolean breed) { setFlag(16, breed); } @@ -85,12 +75,6 @@ public class HorseWatcher extends AgeableWatcher { sendData(20); } - @Deprecated - public void setColorId(int color) { - setValue(20, (color % Color.values().length) & 0xFF | getStyle().ordinal() << 8); - sendData(20); - } - private void setFlag(int i, boolean flag) { int j = (Byte) getValue(16, (byte) 0); if (flag) { @@ -132,12 +116,6 @@ public class HorseWatcher extends AgeableWatcher { sendData(20); } - @Deprecated - public void setStyleId(int style) { - setValue(20, getColor().ordinal() & 0xFF | (style % Style.values().length) << 8); - sendData(20); - } - public void setTamed(boolean tamed) { setFlag(2, tamed); } diff --git a/src/me/libraryaddict/disguise/disguisetypes/watchers/LivingWatcher.java b/src/me/libraryaddict/disguise/disguisetypes/watchers/LivingWatcher.java index 44f0429d..e35add5c 100644 --- a/src/me/libraryaddict/disguise/disguisetypes/watchers/LivingWatcher.java +++ b/src/me/libraryaddict/disguise/disguisetypes/watchers/LivingWatcher.java @@ -6,7 +6,6 @@ import me.libraryaddict.disguise.disguisetypes.Disguise; import me.libraryaddict.disguise.disguisetypes.FlagWatcher; import me.libraryaddict.disguise.utilities.ReflectionManager; -import org.bukkit.potion.PotionEffect; import org.bukkit.potion.PotionEffectType; public class LivingWatcher extends FlagWatcher { @@ -38,14 +37,6 @@ public class LivingWatcher extends FlagWatcher { super(disguise); } - @Deprecated - public void addPotionEffect(PotionEffect potionEffect) { - if (hasPotionEffect(potionEffect.getType())) - removePotionEffect(potionEffect.getType()); - potionEffects.add(potionEffect.getType().getId()); - sendPotionEffects(); - } - public void addPotionEffect(PotionEffectType potionEffect) { if (hasPotionEffect(potionEffect)) removePotionEffect(potionEffect); diff --git a/src/me/libraryaddict/disguise/disguisetypes/watchers/OcelotWatcher.java b/src/me/libraryaddict/disguise/disguisetypes/watchers/OcelotWatcher.java index 860cc075..e8e27243 100644 --- a/src/me/libraryaddict/disguise/disguisetypes/watchers/OcelotWatcher.java +++ b/src/me/libraryaddict/disguise/disguisetypes/watchers/OcelotWatcher.java @@ -58,10 +58,4 @@ public class OcelotWatcher extends AgeableWatcher { setValue(18, (byte) newType.getId()); sendData(18); } - - @Deprecated - public void setTypeId(int type) { - setValue(18, (byte) (type % Type.values().length)); - sendData(18); - } } diff --git a/src/me/libraryaddict/disguise/disguisetypes/watchers/PaintingWatcher.java b/src/me/libraryaddict/disguise/disguisetypes/watchers/PaintingWatcher.java index 1c27ede2..7fc6313f 100644 --- a/src/me/libraryaddict/disguise/disguisetypes/watchers/PaintingWatcher.java +++ b/src/me/libraryaddict/disguise/disguisetypes/watchers/PaintingWatcher.java @@ -30,9 +30,4 @@ public class PaintingWatcher extends FlagWatcher { } } - @Deprecated - public void setArtId(int paintingNo) { - painting = Art.values()[paintingNo % Art.values().length]; - } - } diff --git a/src/me/libraryaddict/disguise/disguisetypes/watchers/VillagerWatcher.java b/src/me/libraryaddict/disguise/disguisetypes/watchers/VillagerWatcher.java index e5bd2679..0aee0454 100644 --- a/src/me/libraryaddict/disguise/disguisetypes/watchers/VillagerWatcher.java +++ b/src/me/libraryaddict/disguise/disguisetypes/watchers/VillagerWatcher.java @@ -10,25 +10,15 @@ public class VillagerWatcher extends AgeableWatcher { public VillagerWatcher(Disguise disguise) { super(disguise); - setProfessionId(new Random().nextInt(Profession.values().length)); + setProfession(Profession.values()[new Random().nextInt(Profession.values().length)]); } public Profession getProfession() { return Profession.values()[(Integer) getValue(16, 0)]; } - @Deprecated - public int getProfessionId() { - return (Integer) getValue(16, 0); - } - public void setProfession(Profession newProfession) { - setProfessionId(newProfession.getId()); - } - - @Deprecated - public void setProfessionId(int profession) { - setValue(16, profession % 6); + setValue(16, newProfession.getId() % 6); sendData(16); } diff --git a/src/me/libraryaddict/disguise/disguisetypes/watchers/ZombieWatcher.java b/src/me/libraryaddict/disguise/disguisetypes/watchers/ZombieWatcher.java index 97d44a11..a001ecb9 100644 --- a/src/me/libraryaddict/disguise/disguisetypes/watchers/ZombieWatcher.java +++ b/src/me/libraryaddict/disguise/disguisetypes/watchers/ZombieWatcher.java @@ -8,9 +8,8 @@ public class ZombieWatcher extends LivingWatcher { super(disguise); } - @Deprecated public boolean isAdult() { - return (Byte) getValue(12, (byte) 0) == 0; + return !isBaby(); } public boolean isBaby() { @@ -21,9 +20,12 @@ public class ZombieWatcher extends LivingWatcher { return (Byte) getValue(13, (byte) 0) == 1; } - @Deprecated - public void setAdult(boolean adult) { - setBaby(!adult); + public void setAdult() { + setBaby(false); + } + + public void setBaby() { + setBaby(true); } public void setBaby(boolean baby) { diff --git a/src/me/libraryaddict/disguise/utilities/BaseDisguiseCommand.java b/src/me/libraryaddict/disguise/utilities/BaseDisguiseCommand.java index 10815c82..427737bc 100644 --- a/src/me/libraryaddict/disguise/utilities/BaseDisguiseCommand.java +++ b/src/me/libraryaddict/disguise/utilities/BaseDisguiseCommand.java @@ -372,34 +372,6 @@ public abstract class BaseDisguiseCommand implements CommandExecutor { return disguise; } - /* private ArrayList getUsableMethods(DisguiseType disguiseType, CommandSender commandSender) { - ArrayList methods = getSettableMethods(disguiseType); - ArrayList allowedDisguises = this.getAllowedDisguises(commandSender); - } - - private ArrayList getSettableMethods(DisguiseType disguiseType) { - ArrayList methods = new ArrayList(); - String[] acceptableParams = new String[] { "String", "boolean", "int", "float", "double", "AnimalColor", "ItemStack", - "ItemStack[]", "Style", "Color", "Type", "Profession", "PotionEffectType" }; - try { - for (Method method : disguiseType.getWatcherClass().getMethods()) { - if (!method.getName().startsWith("get") && method.getParameterTypes().length == 1 - && method.getAnnotation(Deprecated.class) == null) { - Class c = method.getParameterTypes()[0]; - for (String acceptable : acceptableParams) { - if (c.getSimpleName().equals(acceptable)) { - methods.add(method); - break; - } - } - } - } - } catch (Exception ex) { - ex.printStackTrace(); - } - return methods; - }*/// // - private void doCheck(HashSet> optionPermissions, HashSet usedOptions) throws Exception { if (!optionPermissions.isEmpty()) { for (HashSet perms : optionPermissions) {