Skip to content

Commit 39874a7

Browse files
committed
Update version logic fixes #116
1 parent da05596 commit 39874a7

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

cloud-bukkit/src/main/java/org/incendo/cloud/bukkit/internal/CraftBukkitReflection.java

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,15 @@ public final class CraftBukkitReflection {
7474
final Class<?> sharedConstants = needClass("net.minecraft.SharedConstants");
7575
final Method getCurrentVersion = sharedConstants.getDeclaredMethod("getCurrentVersion");
7676
final Object currentVersion = getCurrentVersion.invoke(null);
77-
final Method getName = currentVersion.getClass().getDeclaredMethod("getName");
77+
Method getName = null;
78+
try {
79+
getName = currentVersion.getClass().getDeclaredMethod("getName");
80+
} catch (final NoSuchMethodException ignored) {
81+
}
82+
if (getName == null) {
83+
// ~1.21.6+
84+
getName = currentVersion.getClass().getDeclaredMethod("name");
85+
}
7886
final String versionName = (String) getName.invoke(currentVersion);
7987
try {
8088
fallbackVersion = Integer.parseInt(versionName.split("\\.")[1]);

0 commit comments

Comments
 (0)