修复 NeoForge 版本识别错误的问题 (#3638)

This commit is contained in:
Glavo 2025-02-22 17:28:25 +08:00 committed by GitHub
parent e7e8d45497
commit 72b5428f8b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -216,11 +216,6 @@ public final class LibraryAnalyzer implements Iterable<LibraryAnalyzer.LibraryMa
@Override
protected String patchVersion(Version gameVersion, String libraryVersion) {
Matcher matcher = NEO_FORGE_VERSION_MATCHER.matcher(libraryVersion);
if (matcher.find()) {
return matcher.group("forge");
}
String res = scanVersion(gameVersion);
if (res != null) {
return res;
@ -233,6 +228,11 @@ public final class LibraryAnalyzer implements Iterable<LibraryAnalyzer.LibraryMa
}
}
Matcher matcher = NEO_FORGE_VERSION_MATCHER.matcher(libraryVersion);
if (matcher.find()) {
return matcher.group("forge");
}
return super.patchVersion(gameVersion, libraryVersion);
}
@ -248,12 +248,15 @@ public final class LibraryAnalyzer implements Iterable<LibraryAnalyzer.LibraryMa
for (int i = 0; i < gameArguments.size() - 1; i++) {
Argument argument = gameArguments.get(i);
if (argument instanceof StringArgument && "--fml.neoForgeVersion".equals(((StringArgument) argument).getArgument())) {
Argument next = gameArguments.get(i + 1);
if (next instanceof StringArgument) {
return ((StringArgument) next).getArgument();
if (argument instanceof StringArgument) {
String argumentValue = ((StringArgument) argument).getArgument();
if ("--fml.neoForgeVersion".equals(argumentValue) || "--fml.forgeVersion".equals(argumentValue)) {
Argument next = gameArguments.get(i + 1);
if (next instanceof StringArgument) {
return ((StringArgument) next).getArgument();
}
return null; // Normally, there should not be two --fml.neoForgeVersion argument.
}
return null; // Normally, there should not be two --fml.neoForgeVersion argument.
}
}
return null;