From f81e7bba6b88644148369c89c97aabb5667ff881 Mon Sep 17 00:00:00 2001 From: libraryaddict Date: Sat, 26 Jul 2014 11:08:26 +1200 Subject: [PATCH] Cleaned up LibVersion and added V1_7_6 --- .../disguise/utilities/ReflectionManager.java | 31 +++++++++---------- 1 file changed, 14 insertions(+), 17 deletions(-) diff --git a/src/me/libraryaddict/disguise/utilities/ReflectionManager.java b/src/me/libraryaddict/disguise/utilities/ReflectionManager.java index 89c1f127..0318b3a7 100644 --- a/src/me/libraryaddict/disguise/utilities/ReflectionManager.java +++ b/src/me/libraryaddict/disguise/utilities/ReflectionManager.java @@ -29,23 +29,15 @@ import com.comphenix.protocol.wrappers.WrappedGameProfile; public class ReflectionManager { public enum LibVersion { - V1_6, V1_7; + V1_6, V1_7, V1_7_6; private static LibVersion currentVersion = LibVersion.V1_7; static { - if (getBukkitVersion().startsWith("v1_")) { - try { - int version = Integer.parseInt(getBukkitVersion().split("_")[1]); - if (version == 7) { - currentVersion = LibVersion.V1_7; - } else { - if (version < 7) { - currentVersion = LibVersion.V1_6; - } else { - currentVersion = LibVersion.V1_7; - } - } - } catch (Exception ex) { - ex.printStackTrace(); + String mcVersion = Bukkit.getVersion().split("MC: ")[1].replace(")", ""); + if (mcVersion.startsWith("1.")) { + if (mcVersion.compareTo("1.7") < 0) { + currentVersion = LibVersion.V1_6; + } else { + currentVersion = mcVersion.compareTo("1.7.6") < 0 ? LibVersion.V1_7 : LibVersion.V1_7_6; } } } @@ -59,7 +51,11 @@ public class ReflectionManager { } public static boolean is1_7() { - return getGameVersion() == V1_7; + return is1_7_6() || getGameVersion() == V1_7; + } + + public static boolean is1_7_6() { + return getGameVersion() == V1_7_6; } } @@ -82,7 +78,8 @@ public class ReflectionManager { */ private static Map>> ForgeMethodMappings; private static final Method ihmGet; - private static final boolean isForge = Bukkit.getServer().getName().contains("Cauldron") || Bukkit.getServer().getName().contains("MCPC-Plus"); + private static final boolean isForge = Bukkit.getServer().getName().contains("Cauldron") + || Bukkit.getServer().getName().contains("MCPC-Plus"); private static final Field pingField; private static Map, String> primitiveTypes; private static final Field trackerField;