Skip to content

Commit

Permalink
neoforge: make sure selecting latest beta neoforge excludes non-beta (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
itzg authored Jan 3, 2025
1 parent b76e583 commit 80723b2
Show file tree
Hide file tree
Showing 3 changed files with 683 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ else if (requestedNeoForgeVersion == null || requestedNeoForgeVersion.equalsIgno
.allMatch(i -> parts[i].equals(neoforgeVersion[i]));
}
else {
// specific minecraft version
if (minecraftVersion != null) {
// minor.patch of minecraft version != major.minor of neoforge version
final String minor = minecraftVersion[1];
Expand All @@ -116,11 +117,13 @@ else if (requestedNeoForgeVersion == null || requestedNeoForgeVersion.equalsIgno
}
}

if (parts.length >= 4 && parts[3].equals("beta")) {
return neoForgeVersionType == NeoForgeVersionType.BETA;
// If requesting a beta, then only match a beta version
if (neoForgeVersionType == NeoForgeVersionType.BETA) {
return parts.length >= 4 && parts[3].equals("beta");
}
else {
return parts.length == 3;
}

return true;
}
})
.reduce((s, s2) -> s2)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,17 @@ class NeoForgeInstallerResolverTest {

public static Stream<Arguments> resolve_args() {
return Stream.of(
arguments("1.20.4", "beta", "1.20.4", "20.4.62-beta"),
arguments("1.20.4", "latest", null, null),
arguments("1.20.4", "beta", "1.20.4", "20.4.166-beta"),
arguments("1.21.4", "latest", null, null),
arguments("1.20.2", "latest", "1.20.2", "20.2.88"),
arguments("1.20.2", "beta", "1.20.2", "20.2.88"),
arguments("1.20.2", "beta", "1.20.2", "20.2.85-beta"),
arguments("1.20.3", "beta", "1.20.3", "20.3.8-beta"),
arguments("latest", "20.2.85-beta", "1.20.2", "20.2.85-beta"),
arguments("latest", "20.2.88", "1.20.2", "20.2.88"),
arguments("1.20.1", "latest", "1.20.1", "47.1.84"),
arguments("1.21", "beta", "1.21", "21.0.42-beta")
arguments("1.21", "beta", "1.21", "21.0.142-beta"),
arguments("latest", "beta", "1.21.4", "21.4.48-beta"),
arguments("latest", "latest", "1.21.1", "21.1.93")
);
}

Expand Down Expand Up @@ -67,4 +69,5 @@ void resolve(String minecraftVersion, String neoforgeVersion,

}
}

}
Loading

0 comments on commit 80723b2

Please sign in to comment.