mirror of
https://github.com/PolyhedralDev/Terra.git
synced 2025-07-01 23:47:50 +00:00
Made patch version optional as not all Minecraft versions have a patch number
This commit is contained in:
parent
d810cad8d0
commit
0758e13bc7
@ -9,7 +9,7 @@ import com.dfsek.terra.bukkit.PlatformImpl;
|
||||
|
||||
|
||||
public interface Initializer {
|
||||
String NMS = "v" + VersionUtil.getMinecraftVersionInfo().toString().replace(".", "_");
|
||||
String NMS = VersionUtil.getMinecraftVersionInfo().toString().replace(".", "_");
|
||||
String TERRA_PACKAGE = Initializer.class.getPackageName();
|
||||
|
||||
static boolean init(PlatformImpl platform) {
|
||||
|
@ -77,7 +77,7 @@ public final class VersionUtil {
|
||||
public static final class MinecraftVersionInfo {
|
||||
private static final Logger logger = LoggerFactory.getLogger(MinecraftVersionInfo.class);
|
||||
|
||||
private static final Pattern VERSION_PATTERN = Pattern.compile("(\\d+)\\.(\\d+)\\.(\\d+)");
|
||||
private static final Pattern VERSION_PATTERN = Pattern.compile("(\\d+)\\.(\\d+)(?:\\.(\\d+))?");
|
||||
private final int major;
|
||||
private final int minor;
|
||||
private final int patch;
|
||||
@ -97,7 +97,7 @@ public final class VersionUtil {
|
||||
if(versionMatcher.find()) {
|
||||
major = Integer.parseInt(versionMatcher.group(1));
|
||||
minor = Integer.parseInt(versionMatcher.group(2));
|
||||
patch = Integer.parseInt(versionMatcher.group(3));
|
||||
patch = versionMatcher.group(3) != null ? Integer.parseInt(versionMatcher.group(3)) : -1;
|
||||
} else {
|
||||
logger.warn("Error while parsing minecraft version info. Continuing launch, but setting all versions to -1.");
|
||||
|
||||
@ -112,7 +112,11 @@ public final class VersionUtil {
|
||||
if(major == -1 && minor == -1 && patch == -1)
|
||||
return "Unknown";
|
||||
|
||||
return String.format("v%d.%d.%d", major, minor, patch);
|
||||
if (patch >= 0) {
|
||||
return String.format("v%d.%d.%d", major, minor, patch);
|
||||
} else {
|
||||
return String.format("v%d.%d", major, minor);
|
||||
}
|
||||
}
|
||||
|
||||
public int getMajor() {
|
||||
|
Loading…
x
Reference in New Issue
Block a user