From 353b663e123b28c9613b5a0ccf3aa1fc401ba7c8 Mon Sep 17 00:00:00 2001 From: Gravita <12893402+gravit0@users.noreply.github.com> Date: Fri, 5 Jul 2024 14:38:45 +0700 Subject: [PATCH] [FEATURE] Support command execute by args --- LaunchServer/build.gradle | 1 - .../launchserver/LaunchServerStarter.java | 20 ++++++++++++++++++- 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/LaunchServer/build.gradle b/LaunchServer/build.gradle index bfed90ec..c12ca9a3 100644 --- a/LaunchServer/build.gradle +++ b/LaunchServer/build.gradle @@ -61,7 +61,6 @@ dependsOn jar archiveClassifier.set('clean') manifest.attributes("Main-Class": mainClassName, - "Premain-Class": mainAgentName, "Automatic-Module-Name": "launchserver" ) from sourceSets.main.output diff --git a/LaunchServer/src/main/java/pro/gravit/launchserver/LaunchServerStarter.java b/LaunchServer/src/main/java/pro/gravit/launchserver/LaunchServerStarter.java index addab8f3..0ddb43b3 100644 --- a/LaunchServer/src/main/java/pro/gravit/launchserver/LaunchServerStarter.java +++ b/LaunchServer/src/main/java/pro/gravit/launchserver/LaunchServerStarter.java @@ -34,6 +34,7 @@ import java.nio.file.Path; import java.security.Security; import java.security.cert.CertificateException; +import java.util.ArrayList; import java.util.List; public class LaunchServerStarter { @@ -135,7 +136,24 @@ public static void main(String[] args) throws Exception { .setLaunchServerConfigManager(launchServerConfigManager) .setCertificateManager(certificateManager) .build(); - if (!prepareMode) { + List allArgs = List.of(args); + boolean isPrepareMode = prepareMode || allArgs.contains("--prepare"); + boolean isRunCommand = false; + String runCommand = null; + for(var e : allArgs) { + if(e.equals("--run")) { + isRunCommand = true; + continue; + } + if(isRunCommand) { + runCommand = e; + isRunCommand = false; + } + } + if(runCommand != null) { + localCommandHandler.eval(runCommand, false); + } + if (!isPrepareMode) { server.run(); } else { server.close();