From 240e36aab65944d6aca78e8ef0622af7bb76143f Mon Sep 17 00:00:00 2001 From: Gravita <12893402+gravit0@users.noreply.github.com> Date: Thu, 14 Dec 2023 01:19:36 +0700 Subject: [PATCH] [FIX] Start Forge 1.18+ server --- .../src/main/java/pro/gravit/launcher/api/AuthService.java | 1 + .../pro/gravit/launcher/client/ClientLauncherEntryPoint.java | 1 + .../main/java/pro/gravit/launcher/server/ServerWrapper.java | 5 ++++- 3 files changed, 6 insertions(+), 1 deletion(-) diff --git a/LauncherAPI/src/main/java/pro/gravit/launcher/api/AuthService.java b/LauncherAPI/src/main/java/pro/gravit/launcher/api/AuthService.java index 0020d954..e96152a3 100644 --- a/LauncherAPI/src/main/java/pro/gravit/launcher/api/AuthService.java +++ b/LauncherAPI/src/main/java/pro/gravit/launcher/api/AuthService.java @@ -7,6 +7,7 @@ import java.util.UUID; public class AuthService { + public static String projectName; public static String username; public static ClientPermissions permissions = new ClientPermissions(); public static UUID uuid; 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 15436bd5..81069f83 100644 --- a/LauncherClient/src/main/java/pro/gravit/launcher/client/ClientLauncherEntryPoint.java +++ b/LauncherClient/src/main/java/pro/gravit/launcher/client/ClientLauncherEntryPoint.java @@ -177,6 +177,7 @@ private static void realMain(String[] args) throws Throwable { String glfwPath = ClientService.findLibrary("glfw_wayland"); System.setProperty("org.lwjgl.glfw.libname", glfwPath); } + AuthService.projectName = Launcher.getConfig().projectName; AuthService.username = params.playerProfile.username; AuthService.uuid = params.playerProfile.uuid; KeyService.serverRsaPublicKey = Launcher.getConfig().rsaPublicKey; diff --git a/ServerWrapper/src/main/java/pro/gravit/launcher/server/ServerWrapper.java b/ServerWrapper/src/main/java/pro/gravit/launcher/server/ServerWrapper.java index 4b82b2a3..03466718 100644 --- a/ServerWrapper/src/main/java/pro/gravit/launcher/server/ServerWrapper.java +++ b/ServerWrapper/src/main/java/pro/gravit/launcher/server/ServerWrapper.java @@ -27,6 +27,7 @@ import pro.gravit.utils.helper.SecurityHelper; import pro.gravit.utils.launch.*; +import java.io.File; import java.lang.invoke.MethodHandle; import java.lang.invoke.MethodHandles; import java.lang.invoke.MethodType; @@ -186,9 +187,11 @@ public void run(String... args) throws Throwable { switch (config.classLoaderConfig) { case LAUNCHER: launch = new LegacyLaunch(); + System.setProperty("java.class.path", String.join(File.pathSeparator, config.classpath)); break; case MODULE: launch = new ModuleLaunch(); + System.setProperty("java.class.path", String.join(File.pathSeparator, config.classpath)); break; default: if(ServerAgent.isAgentStarted()) { @@ -213,7 +216,6 @@ public void run(String... args) throws Throwable { config.configServiceSettings.apply(); } LogHelper.info("Start Minecraft Server"); - LogHelper.debug("Invoke main method %s with %s", classname, launch.getClass().getName()); try { if(config.compatClasses != null) { for (String e : config.compatClasses) { @@ -222,6 +224,7 @@ public void run(String... args) throws Throwable { runMethod.invoke(classLoaderControl); } } + LogHelper.debug("Invoke main method %s with %s", classname, launch.getClass().getName()); launch.launch(config.mainclass, config.mainmodule, Arrays.asList(real_args)); } catch (Throwable e) { LogHelper.error(e);