Skip to content

Commit

Permalink
Fix version parser not ignoring the patch component of a Minecraft ve…
Browse files Browse the repository at this point in the history
…rsion if it is zero (#207)
  • Loading branch information
Matyrobbrt authored Dec 22, 2024
1 parent 2f75594 commit 77ffcc8
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,13 @@ static int indexOfNeoForgeVersion(String version) {
if (!matcher.matches()) {
return -1;
}
return MinecraftVersionList.VERSIONS.indexOf("1." + matcher.group(1));

var mcVersion = "1." + matcher.group(1);
// Versions such as 21.0.0 are for Minecraft 1.21 and NOT 1.21.0, therefore we strip the trailing .0
if (mcVersion.endsWith(".0")) {
mcVersion = mcVersion.substring(0, mcVersion.length() - 2);
}
return MinecraftVersionList.VERSIONS.indexOf(mcVersion);
}

public static VersionCapabilities ofNeoForgeVersion(String version) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ public void testJavaVersion(String neoFormVersion, int javaVersion) {

@ParameterizedTest()
@CsvSource({
"21.0.3-beta,1.21",
"21.4.8-beta,1.21.4",
"21.4.10-beta-pr-1744-gh-1582,1.21.4",
"21.4.10,1.21.4",
Expand Down

0 comments on commit 77ffcc8

Please sign in to comment.