Improve version detect

This commit is contained in:
Roman Zhuravlev 2025-09-03 20:01:35 +05:00
parent debb421e38
commit a763850f11

View file

@ -11,12 +11,27 @@ public class MinecraftReflectionVersion {
static { static {
String bukkitPackage = Bukkit.getServer().getClass().getPackage().getName(); String bukkitPackage = Bukkit.getServer().getClass().getPackage().getName();
NMS = bukkitPackage.substring(bukkitPackage.lastIndexOf('.') + 1); String nms = bukkitPackage.substring(bukkitPackage.lastIndexOf('.') + 1);
String[] split = NMS.split("_"); if (nms.contains("_")) {
NMS = nms;
} else {
NMS = "";
}
/*String[] split = NMS.split("_");
MAJOR = Integer.parseInt(split[0].substring(1)); MAJOR = Integer.parseInt(split[0].substring(1));
MINOR = Integer.parseInt(split[1]); MINOR = Integer.parseInt(split[1]);
PATCH = Integer.parseInt(split[2].substring(1, 2)); PATCH = Integer.parseInt(split[2].substring(1, 2));*/
String version = Bukkit.getVersion();
version = version.substring(version.indexOf("(MC: ") + 5, version.length() - 1);
String[] versionParts = version.split("\\.");
MAJOR = Integer.parseInt(versionParts[0]);
MINOR = Integer.parseInt(versionParts[1]);
PATCH = versionParts.length > 2 ? Integer.parseInt(versionParts[2]) : 0;
} }
public static boolean is(int minor) { public static boolean is(int minor) {