From 95e28757b7f9d1b9ff355f0c65f8533e41606fc4 Mon Sep 17 00:00:00 2001 From: libraryaddict Date: Sun, 8 Dec 2013 10:49:41 +1300 Subject: [PATCH] Fixed the version checking being wrong. --- .../disguise/utilities/ReflectionManager.java | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/src/me/libraryaddict/disguise/utilities/ReflectionManager.java b/src/me/libraryaddict/disguise/utilities/ReflectionManager.java index 29373cfa..c3a6a0f9 100644 --- a/src/me/libraryaddict/disguise/utilities/ReflectionManager.java +++ b/src/me/libraryaddict/disguise/utilities/ReflectionManager.java @@ -44,16 +44,18 @@ public class ReflectionManager { } catch (Exception e) { e.printStackTrace(); } - if (bukkitVersion.startsWith("1.")) { + if (bukkitVersion.startsWith("v1_")) { try { - if (Integer.parseInt(bukkitVersion.split("\\.")[1]) < 7) { + if (Integer.parseInt(bukkitVersion.split("_")[1]) < 7) { after17 = false; } } catch (Exception ex) { } } - }public static Object createEntityInstance(String entityName) { + } + + public static Object createEntityInstance(String entityName) { try { Class entityClass = getNmsClass("Entity" + entityName); Object entityObject; @@ -62,15 +64,15 @@ public class ReflectionManager { Object minecraftServer = getNmsClass("MinecraftServer").getMethod("getServer").invoke(null); Object playerinteractmanager = getNmsClass("PlayerInteractManager").getConstructor(getNmsClass("World")) .newInstance(world); - if (!isAfter17()) { - entityObject = entityClass.getConstructor(getNmsClass("MinecraftServer"), getNmsClass("World"), String.class, - playerinteractmanager.getClass()).newInstance(minecraftServer, world, "LibsDisguises", - playerinteractmanager); - } else { + if (isAfter17()) { Object gameProfile = getGameProfile("LibsDisguises"); entityObject = entityClass.getConstructor(getNmsClass("MinecraftServer"), getNmsClass("WorldServer"), gameProfile.getClass(), playerinteractmanager.getClass()).newInstance(minecraftServer, world, gameProfile, playerinteractmanager); + } else { + entityObject = entityClass.getConstructor(getNmsClass("MinecraftServer"), getNmsClass("World"), String.class, + playerinteractmanager.getClass()).newInstance(minecraftServer, world, "LibsDisguises", + playerinteractmanager); } } else { entityObject = entityClass.getConstructor(getNmsClass("World")).newInstance(world);