From d399d80a6c1f37592c26830b261b61ef02aa5f38 Mon Sep 17 00:00:00 2001 From: libraryaddict Date: Sat, 27 Sep 2014 12:17:43 +1200 Subject: [PATCH] Add is1_8 to LibVersion (Uses 1.7 and 1.8 dual build) --- .../disguise/utilities/ReflectionManager.java | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/src/me/libraryaddict/disguise/utilities/ReflectionManager.java b/src/me/libraryaddict/disguise/utilities/ReflectionManager.java index e2738185..2c323351 100644 --- a/src/me/libraryaddict/disguise/utilities/ReflectionManager.java +++ b/src/me/libraryaddict/disguise/utilities/ReflectionManager.java @@ -30,7 +30,7 @@ public class ReflectionManager { public enum LibVersion { V1_6, V1_7, V1_7_10, V1_7_6, V1_8; - private static LibVersion currentVersion = LibVersion.V1_7; + private static LibVersion currentVersion; static { String mcVersion = Bukkit.getVersion().split("MC: ")[1].replace(")", ""); if (mcVersion.startsWith("1.")) { @@ -44,6 +44,12 @@ public class ReflectionManager { } } } + try { + Class.forName("org.spigotmc.ProtocolData"); + currentVersion = V1_8; + } catch (Exception ex) { + // Its not 1.8 + } } public static LibVersion getGameVersion() { @@ -59,12 +65,16 @@ public class ReflectionManager { } public static boolean is1_7_10() { - return getGameVersion() == V1_7_10; + return getGameVersion() == V1_7_10 || is1_8(); } public static boolean is1_7_6() { return getGameVersion() == V1_7_6 || is1_7_10(); } + + public static boolean is1_8() { + return getGameVersion() == V1_8; + } } private static final String bukkitVersion = Bukkit.getServer().getClass().getName().split("\\.")[3]; @@ -551,7 +561,7 @@ public class ReflectionManager { } public static boolean is1_8(Player player) { - if (LibVersion.is1_7_10()) { + if (LibVersion.is1_8()) { if (is1_8.containsKey(player.getName())) { return is1_8.get(player.getName()); }