Added support for MC version up to 1.21.4

This commit is contained in:
LabodiDavid 2024-12-12 22:25:58 +01:00
parent 0227814e72
commit 619548297d
2 changed files with 35 additions and 4 deletions

View File

@ -99,9 +99,9 @@ public final class STPlugin extends JavaPlugin implements CommandExecutor, Liste
try {
this.ServerStartTime = ManagementFactory.getRuntimeMXBean().getStartTime();
if (Version.ServerVersion.isCurrentLower(Version.ServerVersion.v1_12_R1) ||
Version.ServerVersion.isCurrentHigher(Version.ServerVersion.v1_20_R2))
Version.ServerVersion.isCurrentHigher(Version.ServerVersion.v1_21_4_R1))
{
throw new Exception("The server version is not supported! Update to a version between 1.12 - 1.20.2 to run this plugin.");
throw new Exception("The server version is not supported! Update to a version between 1.12 - 1.21.4 to run this plugin.");
}
if (this.reload()) {

View File

@ -28,7 +28,16 @@ public class Version {
v1_19_R1,
v1_19_R2,
v1_20_R1,
v1_20_R2;
v1_20_R2,
v1_20_3_R1,
v1_20_4_R1,
v1_20_5_R1,
v1_20_6_R1,
v1_21_R1,
v1_21_1_R1,
v1_21_2_R1,
v1_21_3_R1,
v1_21_4_R1;
private int value;
@ -59,11 +68,33 @@ public class Version {
return current;
}
public static String[] getArrayVersion() {
/*public static String[] getArrayVersion() {
if (arrayVersion == null) {
arrayVersion = org.bukkit.Bukkit.getServer().getClass().getPackage().getName().split("\\.");
}
return arrayVersion;
}*/
public static String[] getArrayVersion() {
if (arrayVersion == null) {
String packageName = org.bukkit.Bukkit.getServer().getClass().getPackage().getName();
String[] splitPackageName = packageName.split("\\.");
// Check if the splitPackageName length is more than 3
if (splitPackageName.length > 3) {
arrayVersion = new String[] {splitPackageName[3]};
} else {
// Handle the case for newer versions
String version = "UNKNOWN";
try {
version = org.bukkit.Bukkit.getServer().getVersion().split("\\(MC: ")[1].split("\\)")[0];
} catch (Exception e) {
e.printStackTrace();
}
arrayVersion = new String[] {"v" + version.replace('.', '_') + "_R1"};
}
}
return arrayVersion;
}