Skip to content

Commit de51418

Browse files
committed
add VersionUtils
1 parent d0fd700 commit de51418

1 file changed

Lines changed: 23 additions & 0 deletions

File tree

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
package me.hsgamer.mcserverupdater.util;
2+
3+
import java.util.regex.Matcher;
4+
import java.util.regex.Pattern;
5+
6+
public class VersionUtils {
7+
private static final Pattern VERSION_REGEX = Pattern.compile("(\\d+)\\.(\\d+)(\\.(\\d+))?");
8+
9+
public static boolean isAtLeast(String version, int major, int minor) {
10+
Matcher matcher = VERSION_REGEX.matcher(version);
11+
if (!matcher.find()) {
12+
return false;
13+
}
14+
int majorVersion = Integer.parseInt(matcher.group(2));
15+
int minorVersion = Integer.parseInt(matcher.group(4));
16+
17+
return majorVersion > major || (majorVersion == major && minorVersion >= minor);
18+
}
19+
20+
public static boolean isMojmapDefault(String version) {
21+
return isAtLeast(version, 20, 5);
22+
}
23+
}

0 commit comments

Comments
 (0)