Add V1_7_10 to LibVersion for spigot's 1.8 hack
This commit is contained in:
parent
17822426ab
commit
572ebf1bc5
@ -29,7 +29,7 @@ import com.comphenix.protocol.wrappers.WrappedGameProfile;
|
|||||||
public class ReflectionManager {
|
public class ReflectionManager {
|
||||||
|
|
||||||
public enum LibVersion {
|
public enum LibVersion {
|
||||||
V1_6, V1_7, V1_7_6, V1_8;
|
V1_6, V1_7, V1_7_6, V1_7_10, V1_8;
|
||||||
private static LibVersion currentVersion = LibVersion.V1_7;
|
private static LibVersion currentVersion = LibVersion.V1_7;
|
||||||
static {
|
static {
|
||||||
String mcVersion = Bukkit.getVersion().split("MC: ")[1].replace(")", "");
|
String mcVersion = Bukkit.getVersion().split("MC: ")[1].replace(")", "");
|
||||||
@ -37,8 +37,11 @@ public class ReflectionManager {
|
|||||||
if (mcVersion.compareTo("1.7") < 0) {
|
if (mcVersion.compareTo("1.7") < 0) {
|
||||||
currentVersion = LibVersion.V1_6;
|
currentVersion = LibVersion.V1_6;
|
||||||
} else {
|
} else {
|
||||||
currentVersion = mcVersion.compareTo("1.7.6") < 0 && !mcVersion.equals("1.7.10") ? LibVersion.V1_7
|
if (mcVersion.equals("1.7.10")) {
|
||||||
: LibVersion.V1_7_6;
|
currentVersion = LibVersion.V1_7_10;
|
||||||
|
} else {
|
||||||
|
currentVersion = mcVersion.compareTo("1.7.6") < 0 ? LibVersion.V1_7 : LibVersion.V1_7_6;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -52,12 +55,16 @@ public class ReflectionManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static boolean is1_7() {
|
public static boolean is1_7() {
|
||||||
return getGameVersion() == V1_7 || is1_7_6();
|
return getGameVersion() == V1_7 || is1_7_6() || is1_7_10();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean is1_7_6() {
|
public static boolean is1_7_6() {
|
||||||
return getGameVersion() == V1_7_6;
|
return getGameVersion() == V1_7_6;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static boolean is1_7_10() {
|
||||||
|
return getGameVersion() == V1_7_10;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static final String bukkitVersion = Bukkit.getServer().getClass().getName().split("\\.")[3];
|
private static final String bukkitVersion = Bukkit.getServer().getClass().getName().split("\\.")[3];
|
||||||
@ -543,15 +550,17 @@ public class ReflectionManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static boolean is1_8(Player player) {
|
public static boolean is1_8(Player player) {
|
||||||
|
if (LibVersion.is1_7_10()) {
|
||||||
try {
|
try {
|
||||||
Object cPlayer = getNmsEntity(player);
|
Object nmsEntity = getNmsEntity(player);
|
||||||
Field playerConnection = cPlayer.getClass().getField("playerConnection");
|
Object connection = getNmsField(nmsEntity.getClass(), "playerConnection").get(nmsEntity);
|
||||||
Field networkManager = getNmsClass("PlayerConnection").getField("networkManager");
|
Field networkManager = getNmsField(connection.getClass(), "networkManager");
|
||||||
Method getVersion = getNmsClass("NetworkManager").getMethod("getVersion");
|
Method getVersion = getNmsMethod(networkManager.getType(), "getVersion");
|
||||||
return (Integer) getVersion.invoke(networkManager.get(playerConnection.get(cPlayer))) >= 28;
|
return (Integer) getVersion.invoke(networkManager.get(connection)) >= 28;
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
ex.printStackTrace();
|
ex.printStackTrace();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user