[FEATURE] Support command execute by args

This commit is contained in:
Gravita 2024-07-05 14:38:45 +07:00
parent 78be606029
commit 353b663e12
No known key found for this signature in database
GPG key ID: 543A8F335C9CD633
2 changed files with 19 additions and 2 deletions

View file

@ -61,7 +61,6 @@
dependsOn jar dependsOn jar
archiveClassifier.set('clean') archiveClassifier.set('clean')
manifest.attributes("Main-Class": mainClassName, manifest.attributes("Main-Class": mainClassName,
"Premain-Class": mainAgentName,
"Automatic-Module-Name": "launchserver" "Automatic-Module-Name": "launchserver"
) )
from sourceSets.main.output from sourceSets.main.output

View file

@ -34,6 +34,7 @@
import java.nio.file.Path; import java.nio.file.Path;
import java.security.Security; import java.security.Security;
import java.security.cert.CertificateException; import java.security.cert.CertificateException;
import java.util.ArrayList;
import java.util.List; import java.util.List;
public class LaunchServerStarter { public class LaunchServerStarter {
@ -135,7 +136,24 @@ public static void main(String[] args) throws Exception {
.setLaunchServerConfigManager(launchServerConfigManager) .setLaunchServerConfigManager(launchServerConfigManager)
.setCertificateManager(certificateManager) .setCertificateManager(certificateManager)
.build(); .build();
if (!prepareMode) { List<String> 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(); server.run();
} else { } else {
server.close(); server.close();