Fix not booting in 1 dir from root path

This commit is contained in:
IzzelAliz 2021-12-30 15:20:08 +08:00
parent 691727b281
commit 14647e09b9
No known key found for this signature in database
GPG Key ID: EE50E123A11D8338

View File

@ -28,6 +28,7 @@ import java.nio.file.FileSystems;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.nio.file.StandardCopyOption;
import java.security.AccessControlContext;
import java.util.AbstractMap;
import java.util.ArrayList;
@ -233,7 +234,23 @@ public class ForgeInstaller {
exports.add("cpw.mods.bootstraplauncher/cpw.mods.bootstraplauncher=ALL-UNNAMED");
List<String> ignores = new ArrayList<>();
List<String> merges = new ArrayList<>();
var self = new File(ForgeInstaller.class.getProtectionDomain().getCodeSource().getLocation().toURI()).getCanonicalPath();
var self = new File(ForgeInstaller.class.getProtectionDomain().getCodeSource().getLocation().toURI()).toPath();
// todo ugly McModLauncher/securejarhandler#19
if (self.getParent() != null && self.getParent().getParent() != null && self.getParent().getParent().getFileName() == null) {
var folder = self.resolveSibling(".arclight");
var relocation = folder.resolve("tmp.jar");
if (!Files.exists(folder)) {
Files.createDirectories(folder);
}
try {
if (!Files.isSymbolicLink(relocation)) {
Files.createSymbolicLink(relocation, self);
}
} catch (Exception e) {
Files.copy(self, relocation, StandardCopyOption.REPLACE_EXISTING);
}
self = relocation;
}
for (String arg : Files.lines(path).collect(Collectors.toList())) {
if (jvmArgs && arg.startsWith("-")) {
if (arg.startsWith("-p ")) {
@ -247,7 +264,7 @@ public class ForgeInstaller {
if (split[0].equals("legacyClassPath")) {
split[1] =
Stream.concat(
Stream.concat(Stream.of(self, split[1]), installInfo.libraries.keySet().stream()
Stream.concat(Stream.of(self.toString(), split[1]), installInfo.libraries.keySet().stream()
.map(it -> Paths.get("libraries", Util.mavenToPath(it)))
.peek(it -> {
var name = it.getFileName().toString();