Fixed the version checking being wrong.

This commit is contained in:
libraryaddict 2013-12-08 10:49:41 +13:00
parent cdc02b4090
commit 95e28757b7

View File

@ -44,16 +44,18 @@ public class ReflectionManager {
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
} }
if (bukkitVersion.startsWith("1.")) { if (bukkitVersion.startsWith("v1_")) {
try { try {
if (Integer.parseInt(bukkitVersion.split("\\.")[1]) < 7) { if (Integer.parseInt(bukkitVersion.split("_")[1]) < 7) {
after17 = false; after17 = false;
} }
} catch (Exception ex) { } catch (Exception ex) {
} }
} }
}public static Object createEntityInstance(String entityName) { }
public static Object createEntityInstance(String entityName) {
try { try {
Class entityClass = getNmsClass("Entity" + entityName); Class entityClass = getNmsClass("Entity" + entityName);
Object entityObject; Object entityObject;
@ -62,15 +64,15 @@ public class ReflectionManager {
Object minecraftServer = getNmsClass("MinecraftServer").getMethod("getServer").invoke(null); Object minecraftServer = getNmsClass("MinecraftServer").getMethod("getServer").invoke(null);
Object playerinteractmanager = getNmsClass("PlayerInteractManager").getConstructor(getNmsClass("World")) Object playerinteractmanager = getNmsClass("PlayerInteractManager").getConstructor(getNmsClass("World"))
.newInstance(world); .newInstance(world);
if (!isAfter17()) { if (isAfter17()) {
entityObject = entityClass.getConstructor(getNmsClass("MinecraftServer"), getNmsClass("World"), String.class,
playerinteractmanager.getClass()).newInstance(minecraftServer, world, "LibsDisguises",
playerinteractmanager);
} else {
Object gameProfile = getGameProfile("LibsDisguises"); Object gameProfile = getGameProfile("LibsDisguises");
entityObject = entityClass.getConstructor(getNmsClass("MinecraftServer"), getNmsClass("WorldServer"), entityObject = entityClass.getConstructor(getNmsClass("MinecraftServer"), getNmsClass("WorldServer"),
gameProfile.getClass(), playerinteractmanager.getClass()).newInstance(minecraftServer, world, gameProfile.getClass(), playerinteractmanager.getClass()).newInstance(minecraftServer, world,
gameProfile, playerinteractmanager); gameProfile, playerinteractmanager);
} else {
entityObject = entityClass.getConstructor(getNmsClass("MinecraftServer"), getNmsClass("World"), String.class,
playerinteractmanager.getClass()).newInstance(minecraftServer, world, "LibsDisguises",
playerinteractmanager);
} }
} else { } else {
entityObject = entityClass.getConstructor(getNmsClass("World")).newInstance(world); entityObject = entityClass.getConstructor(getNmsClass("World")).newInstance(world);