Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,6 @@

import java.io.File;
import java.lang.invoke.MethodHandles;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class MeteorClient implements ClientModInitializer {
public static final String MOD_ID = "meteor-client";
Expand All @@ -71,9 +69,9 @@ public class MeteorClient implements ClientModInitializer {
LOG = LoggerFactory.getLogger(NAME);

String versionString = MOD_META.getVersion().getFriendlyString();
Matcher matcher = Pattern.compile("(\\d+)\\.(\\d+)\\.(\\d+)").matcher(versionString);
if (versionString.contains("-")) versionString = versionString.split("-")[0];
// When building and running through IntelliJ and not Gradle it doesn't replace the version so just use a dummy
versionString = !matcher.find() ? "0.0.0" : "%s.%s.%s".formatted(matcher.group(1), matcher.group(2), matcher.group(3));
if (versionString.equals("${version}")) versionString = "0.0.0";

VERSION = new Version(versionString);
BUILD_NUMBER = MOD_META.getCustomValue(MeteorClient.MOD_ID + ":build_number").getAsString();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,11 @@ public Version(String string) {
this.numbers = new int[3];

String[] split = string.split("\\.");
if (split.length != 3) throw new IllegalArgumentException("Version string needs to have 3 numbers.");
if (split.length < 2 || split.length > 3) {
throw new IllegalArgumentException("Version string needs to have 2 or 3 numbers.");
}

for (int i = 0; i < 3; i++) {
for (int i = 0; i < split.length; i++) {
try {
numbers[i] = Integer.parseInt(split[i]);
} catch (NumberFormatException _) {
Expand Down
Loading