From 4e101c3ec6c9aaf89e964cdc182099c13dbce9fd Mon Sep 17 00:00:00 2001 From: libraryaddict Date: Tue, 19 Nov 2013 08:39:28 +1300 Subject: [PATCH] Minor code clean --- src/me/libraryaddict/disguise/LibsDisguises.java | 2 +- src/me/libraryaddict/disguise/PacketsManager.java | 2 +- .../libraryaddict/disguise/ReflectionManager.java | 11 +++-------- .../disguise/disguisetypes/Values.java | 14 -------------- 4 files changed, 5 insertions(+), 24 deletions(-) diff --git a/src/me/libraryaddict/disguise/LibsDisguises.java b/src/me/libraryaddict/disguise/LibsDisguises.java index 7fad6c42..0dc642fb 100644 --- a/src/me/libraryaddict/disguise/LibsDisguises.java +++ b/src/me/libraryaddict/disguise/LibsDisguises.java @@ -171,7 +171,7 @@ public class LibsDisguises extends JavaPlugin { break; } try { - Object entity = ReflectionManager.getEntityInstance(name); + Object entity = ReflectionManager.createEntityInstance(name); Entity bukkitEntity = (Entity) ReflectionManager.getNmsClass("Entity").getMethod("getBukkitEntity") .invoke(entity); int size = 0; diff --git a/src/me/libraryaddict/disguise/PacketsManager.java b/src/me/libraryaddict/disguise/PacketsManager.java index 0b0a3a81..c0a2a49a 100644 --- a/src/me/libraryaddict/disguise/PacketsManager.java +++ b/src/me/libraryaddict/disguise/PacketsManager.java @@ -612,7 +612,7 @@ public class PacketsManager { Packets.Server.REL_ENTITY_MOVE_LOOK, Packets.Server.ENTITY_LOOK, Packets.Server.ENTITY_TELEPORT, Packets.Server.ENTITY_HEAD_ROTATION, Packets.Server.ENTITY_METADATA, Packets.Server.ENTITY_EQUIPMENT, Packets.Server.ARM_ANIMATION, Packets.Server.ENTITY_LOCATION_ACTION, Packets.Server.MOB_EFFECT, - /* Packets.Server.ENTITY_STATUS, */Packets.Server.ENTITY_VELOCITY, Packets.Server.UPDATE_ATTRIBUTES) { + Packets.Server.ENTITY_VELOCITY, Packets.Server.UPDATE_ATTRIBUTES) { @Override public void onPacketSending(PacketEvent event) { StructureModifier entityModifer = event.getPacket().getEntityModifier(event.getPlayer().getWorld()); diff --git a/src/me/libraryaddict/disguise/ReflectionManager.java b/src/me/libraryaddict/disguise/ReflectionManager.java index 473dac3e..c1eaca0e 100644 --- a/src/me/libraryaddict/disguise/ReflectionManager.java +++ b/src/me/libraryaddict/disguise/ReflectionManager.java @@ -20,7 +20,7 @@ public class ReflectionManager { try { if (method.getReturnType() == float.class && Modifier.isProtected(method.getModifiers()) && method.getParameterTypes().length == 0) { - Object entity = getEntityInstance("Pig"); + Object entity = createEntityInstance("Pig"); method.setAccessible(true); method.invoke(entity); Field random = getNmsClass("Entity").getDeclaredField("random"); @@ -79,11 +79,11 @@ public class ReflectionManager { return null; } - public static Object getEntityInstance(String entityName) { + public static Object createEntityInstance(String entityName) { try { Class entityClass = getNmsClass("Entity" + entityName); Object entityObject; - Object world = getWorld(); + Object world = getWorld(Bukkit.getWorlds().get(0)); if (entityName.equals("Player")) { Object minecraftServer = getNmsClass("MinecraftServer").getMethod("getServer").invoke(null); Object playerinteractmanager = getNmsClass("PlayerInteractManager").getConstructor(getNmsClass("World")) @@ -121,7 +121,6 @@ public class ReflectionManager { public static Float getSoundModifier(Object entity) { try { - // TODO Update this each update! soundMethod.setAccessible(true); return (Float) soundMethod.invoke(entity); } catch (Exception ex) { @@ -129,10 +128,6 @@ public class ReflectionManager { return null; } - private static Object getWorld() { - return getWorld(Bukkit.getWorlds().get(0)); - } - public static Object getWorld(World world) { try { return getCraftClass("CraftWorld").getMethod("getHandle").invoke(world); diff --git a/src/me/libraryaddict/disguise/disguisetypes/Values.java b/src/me/libraryaddict/disguise/disguisetypes/Values.java index 091ac183..38084444 100644 --- a/src/me/libraryaddict/disguise/disguisetypes/Values.java +++ b/src/me/libraryaddict/disguise/disguisetypes/Values.java @@ -6,10 +6,6 @@ public class Values { private static HashMap values = new HashMap(); - /* public static HashMap getAttributesValues(DisguiseType type) { - return getValues(type).getAttributesValues(); - }*/ - public static Class getEntityClass(DisguiseType type) { return getValues(type).getEntityClass(); } @@ -45,8 +41,6 @@ public class Values { return values.get(type); } - // private HashMap attributesValues = new HashMap(); - private Class declared; private int enumEntitySize; @@ -58,10 +52,6 @@ public class Values { declared = classType; } - /*public HashMap getAttributesValues() { - return attributesValues; - }*/ - public Class getEntityClass() { return declared; } @@ -113,10 +103,6 @@ public class Values { return metaValues; } - /*public void setAttributesValue(String attribute, Double value) { - attributesValues.put(attribute, value); - }*/ - public void setMetaValue(int no, Object value) { metaValues.put(no, value); }