fix: cannot launch game with bootstraplauncher > 0.1.17.

This commit is contained in:
huanghongxun 2021-08-14 18:29:25 +08:00
parent 7d1f50519c
commit e61af71415
3 changed files with 33 additions and 10 deletions

View File

@ -158,7 +158,8 @@ public final class LibraryAnalyzer implements Iterable<LibraryAnalyzer.LibraryMa
FABRIC(true, "fabric", Pattern.compile("net\\.fabricmc"), Pattern.compile("fabric-loader")),
FORGE(true, "forge", Pattern.compile("net\\.minecraftforge"), Pattern.compile("(forge|fmlloader)")),
LITELOADER(true, "liteloader", Pattern.compile("com\\.mumfrey"), Pattern.compile("liteloader")),
OPTIFINE(false, "optifine", Pattern.compile("(net\\.)?optifine"), Pattern.compile("^(?!.*launchwrapper).*$"));
OPTIFINE(false, "optifine", Pattern.compile("(net\\.)?optifine"), Pattern.compile("^(?!.*launchwrapper).*$")),
BOOTSTRAP_LAUNCHER(false, "", Pattern.compile("cpw\\.mods"), Pattern.compile("bootstraplauncher"));
private final boolean modLoader;
private final String patchId;

View File

@ -187,14 +187,35 @@ public class MaintainTask extends Task<Version> {
if (!libraryAnalyzer.has(FORGE)) return version;
// The default ignoreList set by Forge installer does not fulfill our requirements
List<Argument> jvm = builder.getMutableJvmArguments();
for (int i = 0; i < jvm.size(); i++) {
Argument jvmArg = jvm.get(i);
if (jvmArg instanceof StringArgument) {
String jvmArgStr = jvmArg.toString();
if (jvmArgStr.startsWith("-DignoreList=")) {
jvm.set(i, new StringArgument("-DignoreList=" + updateIgnoreList(repository, version, jvmArgStr.substring("-DignoreList=".length()))));
Optional<String> bslVersion = libraryAnalyzer.getVersion(BOOTSTRAP_LAUNCHER);
if (bslVersion.isPresent()) {
if (VersionNumber.VERSION_COMPARATOR.compare(bslVersion.get(), "0.1.17") < 0) {
// The default ignoreList will be applied to all components of libraries in classpath,
// so if game directory located in some directory like /Users/asm, all libraries will be ignored,
// which is not expected. We fix this here.
List<Argument> jvm = builder.getMutableJvmArguments();
for (int i = 0; i < jvm.size(); i++) {
Argument jvmArg = jvm.get(i);
if (jvmArg instanceof StringArgument) {
String jvmArgStr = jvmArg.toString();
if (jvmArgStr.startsWith("-DignoreList=")) {
jvm.set(i, new StringArgument("-DignoreList=" + updateIgnoreList(repository, version, jvmArgStr.substring("-DignoreList=".length()))));
}
}
}
} else {
// bootstraplauncher 0.1.17 will only apply ignoreList to file name of libraries in classpath.
// So we only fixes name of primary jar.
List<Argument> jvm = builder.getMutableJvmArguments();
for (int i = 0; i < jvm.size(); i++) {
Argument jvmArg = jvm.get(i);
if (jvmArg instanceof StringArgument) {
String jvmArgStr = jvmArg.toString();
if (jvmArgStr.startsWith("-DignoreList=")) {
jvm.set(i, new StringArgument(jvmArgStr + ",${primary_jar_name}"));
}
}
}
}
}

View File

@ -304,7 +304,8 @@ public class DefaultLauncher extends Launcher {
// when we propose this placeholder.
pair("${libraries_directory}", repository.getLibrariesDirectory(version).getAbsolutePath()),
// file_separator is used in -DignoreList
pair("${file_separator}", OperatingSystem.FILE_SEPARATOR)
pair("${file_separator}", OperatingSystem.FILE_SEPARATOR),
pair("${primary_jar_name}", FileUtils.getName(repository.getVersionJar(version).toPath()))
);
}