From cc6ed82afb76a88c27394a9a8d8f54317781eda4 Mon Sep 17 00:00:00 2001 From: Gravita <12893402+gravit0@users.noreply.github.com> Date: Sun, 14 Apr 2024 20:53:09 +0700 Subject: [PATCH] [FIX] Forge 1.7.10 lwjgl3ify classpath order --- .../helper/MakeProfileHelper.java | 3 +++ .../runtime/client/ClientLauncherProcess.java | 2 +- .../client/ClientLauncherEntryPoint.java | 26 +++++++++++++------ 3 files changed, 22 insertions(+), 9 deletions(-) diff --git a/LaunchServer/src/main/java/pro/gravit/launchserver/helper/MakeProfileHelper.java b/LaunchServer/src/main/java/pro/gravit/launchserver/helper/MakeProfileHelper.java index d627d3ed..50cf3ba9 100644 --- a/LaunchServer/src/main/java/pro/gravit/launchserver/helper/MakeProfileHelper.java +++ b/LaunchServer/src/main/java/pro/gravit/launchserver/helper/MakeProfileHelper.java @@ -31,6 +31,9 @@ public static ClientProfile makeProfile(ClientProfile.Version version, String ti builder.setUpdateVerify(List.of("libraries", "natives", "mods", "minecraft.jar", "forge.jar", "liteloader.jar")); { List classPath = new ArrayList<>(5); + if(findOption(options, MakeProfileOptionLaunchWrapper.class).isPresent()) { + classPath.add("libraries/net/minecraft/launchwrapper/1.12/launchwrapper-1.12.jar"); + } classPath.add("libraries"); classPath.add("minecraft.jar"); if (version.compareTo(ClientProfileVersions.MINECRAFT_1_12_2) <= 0) { diff --git a/Launcher/src/main/java/pro/gravit/launcher/runtime/client/ClientLauncherProcess.java b/Launcher/src/main/java/pro/gravit/launcher/runtime/client/ClientLauncherProcess.java index 9f8b3293..4928f57c 100644 --- a/Launcher/src/main/java/pro/gravit/launcher/runtime/client/ClientLauncherProcess.java +++ b/Launcher/src/main/java/pro/gravit/launcher/runtime/client/ClientLauncherProcess.java @@ -147,7 +147,7 @@ public void start(boolean pipeOutput) throws IOException, InterruptedException { if (params.profile.getClassLoaderConfig() == ClientProfile.ClassLoaderConfig.AGENT) { processArgs.add("-javaagent:".concat(IOHelper.getCodeSource(ClientLauncherEntryPoint.class).toAbsolutePath().toString())); } else if (params.profile.getClassLoaderConfig() == ClientProfile.ClassLoaderConfig.SYSTEM_ARGS) { - systemClassPath.addAll(ClientLauncherEntryPoint.resolveClassPath(workDir, params.actions, params.profile) + systemClassPath.addAll(ClientLauncherEntryPoint.resolveClassPath(new HashSet<>(), workDir, params.actions, params.profile) .filter(x -> !params.profile.getModulePath().contains(workDir.relativize(x).toString())) .map(Path::toString) .toList()); diff --git a/LauncherClient/src/main/java/pro/gravit/launcher/client/ClientLauncherEntryPoint.java b/LauncherClient/src/main/java/pro/gravit/launcher/client/ClientLauncherEntryPoint.java index 6c83934e..eb476436 100644 --- a/LauncherClient/src/main/java/pro/gravit/launcher/client/ClientLauncherEntryPoint.java +++ b/LauncherClient/src/main/java/pro/gravit/launcher/client/ClientLauncherEntryPoint.java @@ -118,7 +118,8 @@ private static void realMain(String[] args) throws Throwable { // Verify ClientLauncher sign and classpath LogHelper.debug("Verifying ClientLauncher sign and classpath"); - List classpath = resolveClassPath(clientDir, params.actions, params.profile) + Set ignoredPath = new HashSet<>(); + List classpath = resolveClassPath(ignoredPath, clientDir, params.actions, params.profile) .filter(x -> !profile.getModulePath().contains(clientDir.relativize(x).toString())) .collect(Collectors.toCollection(ArrayList::new)); if(LogHelper.isDevEnabled()) { @@ -252,11 +253,11 @@ public static void verifyHDir(Path dir, HashedDir hdir, FileNameMatcher matcher, } } - private static LinkedList resolveClassPathList(Path clientDir, String... classPath) throws IOException { - return resolveClassPathStream(clientDir, classPath).collect(Collectors.toCollection(LinkedList::new)); + private static LinkedList resolveClassPathList(Set ignorePaths, Path clientDir, String... classPath) throws IOException { + return resolveClassPathStream(ignorePaths, clientDir, classPath).collect(Collectors.toCollection(LinkedList::new)); } - private static Stream resolveClassPathStream(Path clientDir, String... classPath) throws IOException { + private static Stream resolveClassPathStream(Set ignorePaths, Path clientDir, String... classPath) throws IOException { Stream.Builder builder = Stream.builder(); for (String classPathEntry : classPath) { Path path = clientDir.resolve(IOHelper.toPath(classPathEntry.replace(IOHelper.CROSS_SEPARATOR, IOHelper.PLATFORM_SEPARATOR))); @@ -265,20 +266,28 @@ private static Stream resolveClassPathStream(Path clientDir, String... cla IOHelper.walk(path, new ClassPathFileVisitor(jars), false); Collections.sort(jars); for(var e : jars) { + if(ignorePaths.contains(e)) { + continue; + } builder.accept(e); + ignorePaths.add(e); } continue; } + if(ignorePaths.contains(path)) { + continue; + } builder.accept(path); + ignorePaths.add(path); } return builder.build(); } - public static Stream resolveClassPath(Path clientDir, Set actions, ClientProfile profile) throws IOException { - Stream result = resolveClassPathStream(clientDir, profile.getClassPath()); + public static Stream resolveClassPath(Set ignorePaths, Path clientDir, Set actions, ClientProfile profile) throws IOException { + Stream result = resolveClassPathStream(ignorePaths, clientDir, profile.getClassPath()); for (OptionalAction a : actions) { if (a instanceof OptionalActionClassPath) - result = Stream.concat(result, resolveClassPathStream(clientDir, ((OptionalActionClassPath) a).args)); + result = Stream.concat(result, resolveClassPathStream(ignorePaths, clientDir, ((OptionalActionClassPath) a).args)); } return result; } @@ -340,8 +349,9 @@ private ClassPathFileVisitor(List result) { @Override public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IOException { - if (IOHelper.hasExtension(file, "jar") || IOHelper.hasExtension(file, "zip")) + if (IOHelper.hasExtension(file, "jar") || IOHelper.hasExtension(file, "zip")) { result.add(file); + } return super.visitFile(file, attrs); } }