Fix version detection from spigot

This commit is contained in:
Lukas Rieger (Blue) 2024-06-24 23:13:06 +02:00
parent 6032043126
commit 62174c60c5
No known key found for this signature in database
GPG Key ID: AA33883B1BBA03E6

View File

@ -80,6 +80,11 @@ public BukkitPlugin() {
Matcher versionMatcher = Pattern.compile("(\\d+(?:\\.\\d+){1,2})[-_].*").matcher(versionString);
if (!versionMatcher.matches()) throw new IllegalArgumentException();
version = versionMatcher.group(1);
// minecraft omits .0 in its versions (e.g. 1.21 instead of 1.21.0) so we should remove it as well
if (version.endsWith(".0"))
version = version.substring(0, version.length() - 2);
} catch (IllegalArgumentException e) {
Logger.global.logWarning("Failed to detect the minecraft version of this server! Using latest version.");
}