From afbed1345fffd2011734a50ca23653e5a0ee7e51 Mon Sep 17 00:00:00 2001 From: Gravita Date: Fri, 11 Mar 2022 15:55:54 +0700 Subject: [PATCH] [FEATURE] Support customJvmOptions --- .../pro/gravit/launchserver/binary/tasks/MainBuildTask.java | 1 + .../pro/gravit/launchserver/config/LaunchServerConfig.java | 5 ++--- .../main/java/pro/gravit/launcher/ClientLauncherWrapper.java | 5 +++++ 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/LaunchServer/src/main/java/pro/gravit/launchserver/binary/tasks/MainBuildTask.java b/LaunchServer/src/main/java/pro/gravit/launchserver/binary/tasks/MainBuildTask.java index 873bf6ce..c9dc6487 100644 --- a/LaunchServer/src/main/java/pro/gravit/launchserver/binary/tasks/MainBuildTask.java +++ b/LaunchServer/src/main/java/pro/gravit/launchserver/binary/tasks/MainBuildTask.java @@ -111,6 +111,7 @@ protected void initProps() { properties.put("launcher.guardType", server.config.launcher.guardType); properties.put("launchercore.env", server.config.env); properties.put("launcher.memory", server.config.launcher.memoryLimit); + properties.put("launcher.customJvmOptions", server.config.launcher.customJvmOptions); if (server.config.launcher.encryptRuntime) { if (server.runtime.runtimeEncryptKey == null) server.runtime.runtimeEncryptKey = SecurityHelper.randomStringToken(); diff --git a/LaunchServer/src/main/java/pro/gravit/launchserver/config/LaunchServerConfig.java b/LaunchServer/src/main/java/pro/gravit/launchserver/config/LaunchServerConfig.java index 2f5d8bcb..d7fb793c 100644 --- a/LaunchServer/src/main/java/pro/gravit/launchserver/config/LaunchServerConfig.java +++ b/LaunchServer/src/main/java/pro/gravit/launchserver/config/LaunchServerConfig.java @@ -23,9 +23,7 @@ import pro.gravit.utils.helper.JVMHelper; import java.io.File; -import java.util.Arrays; -import java.util.HashMap; -import java.util.Map; +import java.util.*; public final class LaunchServerConfig { private transient final Logger logger = LogManager.getLogger(); @@ -292,6 +290,7 @@ public static class LauncherConf { public boolean deleteTempFiles; public boolean certificatePinning; public boolean encryptRuntime; + public List customJvmOptions = new ArrayList<>(); public int memoryLimit = 256; } diff --git a/Launcher/src/main/java/pro/gravit/launcher/ClientLauncherWrapper.java b/Launcher/src/main/java/pro/gravit/launcher/ClientLauncherWrapper.java index 8ca990e0..6d0ca26b 100644 --- a/Launcher/src/main/java/pro/gravit/launcher/ClientLauncherWrapper.java +++ b/Launcher/src/main/java/pro/gravit/launcher/ClientLauncherWrapper.java @@ -20,6 +20,8 @@ public class ClientLauncherWrapper { public static boolean waitProcess = Boolean.getBoolean(WAIT_PROCESS_PROPERTY); @LauncherInject("launcher.memory") public static int launcherMemoryLimit; + @LauncherInject("launcher.customJvmOptions") + public static List customJvmOptions; public static void main(String[] arguments) throws IOException, InterruptedException { LogHelper.printVersion("Launcher"); @@ -138,6 +140,9 @@ public static void main(String[] arguments) throws IOException, InterruptedExcep if (context.memoryLimit != 0) { args.add(String.format("-Xmx%dM", context.memoryLimit)); } + if(customJvmOptions != null) { + args.addAll(customJvmOptions); + } args.add("-cp"); args.add(String.join(IOHelper.PLATFORM_SEPARATOR, context.classpath)); args.add(context.mainClass);