Skip to content

Commit

Permalink
add VersionUtils
Browse files Browse the repository at this point in the history
  • Loading branch information
HSGamer committed Jun 1, 2024
1 parent d0fd700 commit de51418
Showing 1 changed file with 23 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package me.hsgamer.mcserverupdater.util;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class VersionUtils {
private static final Pattern VERSION_REGEX = Pattern.compile("(\\d+)\\.(\\d+)(\\.(\\d+))?");

public static boolean isAtLeast(String version, int major, int minor) {
Matcher matcher = VERSION_REGEX.matcher(version);
if (!matcher.find()) {
return false;
}
int majorVersion = Integer.parseInt(matcher.group(2));
int minorVersion = Integer.parseInt(matcher.group(4));

return majorVersion > major || (majorVersion == major && minorVersion >= minor);
}

public static boolean isMojmapDefault(String version) {
return isAtLeast(version, 20, 5);
}
}

0 comments on commit de51418

Please sign in to comment.