mirror of
https://github.com/NoCheatPlus/NoCheatPlus.git
synced 2025-01-15 03:51:20 +01:00
Ensure to detect the Minecraft version from the spigot server string.
This commit is contained in:
parent
40d3328c87
commit
a4240dcb69
@ -25,6 +25,7 @@ public class ServerVersion {
|
||||
*/
|
||||
public static String parseMinecraftVersion(String... versionCandidates) {
|
||||
for (String serverVersion : versionCandidates) {
|
||||
serverVersion = serverVersion.trim();
|
||||
for (String minecraftVersion : new String[]{
|
||||
collectVersion(serverVersion, 0),
|
||||
parseMinecraftVersionGeneric(serverVersion),
|
||||
@ -108,7 +109,7 @@ public class ServerVersion {
|
||||
private static String parseMinecraftVersionGeneric(String serverVersion) {
|
||||
String lcServerVersion = serverVersion.trim().toLowerCase();
|
||||
for (String candidate : new String[] {
|
||||
// git-bukkit-MC_VERSION-rX.Y
|
||||
parseVersionDelimiters(lcServerVersion, "(mc:", ")"),
|
||||
parseVersionDelimiters(lcServerVersion, "git-bukkit-", "-r"),
|
||||
parseVersionDelimiters(lcServerVersion, "", "-r"),
|
||||
// TODO: Other server mods + custom builds !?.
|
||||
@ -133,7 +134,7 @@ public class ServerVersion {
|
||||
String candidate = input.substring(preIndex + prefix.length());
|
||||
int postIndex = suffix.isEmpty() ? candidate.length() : candidate.indexOf(suffix);
|
||||
if (postIndex != -1) {
|
||||
return collectVersion(candidate.substring(0, postIndex), 0);
|
||||
return collectVersion(candidate.substring(0, postIndex).trim(), 0);
|
||||
}
|
||||
}
|
||||
return null;
|
||||
|
@ -15,6 +15,7 @@ public class TestMinecraftVersion {
|
||||
{"1.7.5", "1.7.5"},
|
||||
{"1.7.5", "1.7.5-R0.1-SNAPSHOT"},
|
||||
{"1.7.2", "git-Bukkit-1.7.2-R0.3-14-g8f8716c-b3042jnks"},
|
||||
{"1.8", "git-Spigot-081dfa5-7658819 (MC: 1.8)"}
|
||||
}) {
|
||||
String parsed = ServerVersion.parseMinecraftVersion(pair[1]);
|
||||
if (pair[0] == null) {
|
||||
|
Loading…
Reference in New Issue
Block a user