Skip to content

Commit

Permalink
Made incorrect game versions not crash the game.
Browse files Browse the repository at this point in the history
  • Loading branch information
MartinSVK12 committed Dec 17, 2023
1 parent 949cd51 commit 92a82de
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
public final class McVersionLookup {
private static final Pattern VERSION_PATTERN = Pattern.compile(
"0\\.\\d+(\\.\\d+)?a?(_\\d+)?|" // match classic versions first: 0.1.2a_34
+ "\\d+\\.\\d+(\\.\\d+)?(-pre\\d+| Pre-?[Rr]elease \\d+)?|" // modern non-snapshot: 1.2, 1.2.3, optional -preN or " Pre-Release N" suffix
+ "\\d+\\.\\d+(\\.\\d+)?(-pre\\d+| Pre-?[Rr]elease \\d.?+)?|" // modern non-snapshot: 1.2, 1.2.3, optional -preN or " Pre-Release N" suffix
+ "\\d+\\.\\d+(\\.\\d+)?(-rc\\d+| [Rr]elease Candidate \\d+)?|" // 1.16+ Release Candidate
+ "\\d+w\\d+[a-z]|" // modern snapshot: 12w34a
+ "[a-c]\\d\\.\\d+(\\.\\d+)?[a-z]?(_\\d+)?[a-z]?|" // alpha/beta a1.2.3_45
Expand All @@ -60,7 +60,7 @@ public final class McVersionLookup {
+ "(.*[Ee]xperimental [Ss]napshot )(\\d+)" // Experimental versions.
);
private static final Pattern RELEASE_PATTERN = Pattern.compile("\\d+\\.\\d+(\\.\\d+)?");
private static final Pattern PRE_RELEASE_PATTERN = Pattern.compile(".+(?:-pre| Pre-?[Rr]elease )(\\d+)");
private static final Pattern PRE_RELEASE_PATTERN = Pattern.compile(".+(?:-pre| Pre-?[Rr]elease )(\\d.?+)");
private static final Pattern RELEASE_CANDIDATE_PATTERN = Pattern.compile(".+(?:-rc| [Rr]elease Candidate )(\\d+)");
private static final Pattern SNAPSHOT_PATTERN = Pattern.compile("(?:Snapshot )?(\\d+)w0?(0|[1-9]\\d*)([a-z])");
private static final Pattern EXPERIMENTAL_PATTERN = Pattern.compile("(?:.*[Ee]xperimental [Ss]napshot )(\\d+)");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -578,7 +578,7 @@ private boolean hasStrInMethod(String cls, String methodName, String methodDesc,

private Version getGameVersion() {
try {
return VersionParser.parseSemantic(gameProvider.getNormalizedGameVersion());
return VersionParser.parse(gameProvider.getNormalizedGameVersion(),false);
} catch (VersionParsingException e) {
throw new RuntimeException(e);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ public final class FabricLoaderImpl extends net.fabricmc.loader.FabricLoader {

public static final int ASM_VERSION = Opcodes.ASM9;

public static final String VERSION = "0.14.19-babric.1";
public static final String VERSION = "0.14.19-babric.3-bta";
public static final String MOD_ID = "fabricloader";

public static final String CACHE_DIR_NAME = ".fabric"; // relative to game dir
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ public Builder(String id, String version) {
this.name = this.id = id;

try {
this.version = VersionParser.parseSemantic(version);
this.version = VersionParser.parse(version,false);
} catch (VersionParsingException e) {
throw new RuntimeException(e);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ public static Version parse(String s, boolean storeX) throws VersionParsingExcep
try {
version = new SemanticVersionImpl(s, storeX);
} catch (VersionParsingException e) {
System.err.println(e.getMessage());
version = new StringVersion(s);
}

Expand Down

0 comments on commit 92a82de

Please sign in to comment.