Skip to content

Commit 67d9f00

Browse files
committed
fix: 0.2.42.2 - fixed Spigot 1.21.11 newer builds support
1 parent af467b9 commit 67d9f00

File tree

2 files changed

+21
-10
lines changed

2 files changed

+21
-10
lines changed

gradle.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
version=0.2.42.1
1+
version=0.2.42.2
22

33
org.gradle.caching=true
44
org.gradle.parallel=true

plugin/src/main/java/org/screamingsandals/bedwars/utils/VersionFallback.java

Lines changed: 20 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,13 @@ public static void applyFallbackIfNeeded() {
3636
String[] mappingNamespaces = MapperPlatforms.getCurrentPlatform().getMappingNamespaces();
3737
String version = MapperPlatforms.getCurrentPlatform().getVersion();
3838

39+
if ("1.21.11 Unobfuscated".equals(version)) {
40+
// fix support for later spigot builds of 1.21.11, which has broken version string
41+
// (because they are built from the 1.21.11_unobfuscated version jar despite the fact the result is obfuscated)
42+
MapperPlatforms.setCurrentPlatform(MapperPlatform.create("1.21.11", MapperPlatforms.getCurrentPlatform().getClassLoader(), mappingNamespaces));
43+
version = "1.21.11";
44+
}
45+
3946
if (MinecraftServerAccessor.TYPE.get() != null) {
4047
// everything is fine, we support this version
4148
Bukkit.getLogger().info("[BedWars] Loaded NMS modules for " + version + " in namespaces " + Arrays.toString(mappingNamespaces));
@@ -71,17 +78,21 @@ public static void applyFallbackIfNeeded() {
7178
}
7279

7380
private static int compareVersions(String v1, String v2) {
74-
String[] parts1 = v1.split("\\.");
75-
String[] parts2 = v2.split("\\.");
76-
int length = Math.max(parts1.length, parts2.length);
81+
try {
82+
String[] parts1 = v1.split("\\.");
83+
String[] parts2 = v2.split("\\.");
84+
int length = Math.max(parts1.length, parts2.length);
7785

78-
for (int i = 0; i < length; i++) {
79-
int num1 = i < parts1.length ? Integer.parseInt(parts1[i]) : 0;
80-
int num2 = i < parts2.length ? Integer.parseInt(parts2[i]) : 0;
81-
if (num1 != num2) {
82-
return Integer.compare(num1, num2);
86+
for (int i = 0; i < length; i++) {
87+
int num1 = i < parts1.length ? Integer.parseInt(parts1[i]) : 0;
88+
int num2 = i < parts2.length ? Integer.parseInt(parts2[i]) : 0;
89+
if (num1 != num2) {
90+
return Integer.compare(num1, num2);
91+
}
8392
}
93+
return 0;
94+
} catch (NumberFormatException e) {
95+
return -1;
8496
}
85-
return 0;
8697
}
8798
}

0 commit comments

Comments
 (0)