From 21e67328c75850cbaa7a144d4ef3ec7a50fe921e Mon Sep 17 00:00:00 2001 From: Matthew Miller Date: Sat, 11 Nov 2017 15:42:16 +1000 Subject: [PATCH] Added server argument to configuration --- .../com/skcraft/launcher/Configuration.java | 3 +++ .../com/skcraft/launcher/launch/Runner.java | 20 +++++++++++++++++++ 2 files changed, 23 insertions(+) diff --git a/launcher/src/main/java/com/skcraft/launcher/Configuration.java b/launcher/src/main/java/com/skcraft/launcher/Configuration.java index 28ea11650..d1e063896 100644 --- a/launcher/src/main/java/com/skcraft/launcher/Configuration.java +++ b/launcher/src/main/java/com/skcraft/launcher/Configuration.java @@ -35,6 +35,9 @@ public class Configuration { private String proxyUsername; private String proxyPassword; private String gameKey; + private boolean serverEnabled = false; + private String serverHost; + private int serverPort = 25565; @Override public boolean equals(Object o) { diff --git a/launcher/src/main/java/com/skcraft/launcher/launch/Runner.java b/launcher/src/main/java/com/skcraft/launcher/launch/Runner.java index 10d70fe55..833d73316 100644 --- a/launcher/src/main/java/com/skcraft/launcher/launch/Runner.java +++ b/launcher/src/main/java/com/skcraft/launcher/launch/Runner.java @@ -136,6 +136,7 @@ public Process call() throws Exception { addLibraries(); addJarArgs(); addProxyArgs(); + addServerArgs(); addWindowArgs(); addPlatformArgs(); addLegacyArgs(); @@ -305,6 +306,25 @@ private void addProxyArgs() { } } + /** + * Add server arguments. + */ + private void addServerArgs() { + List args = builder.getArgs(); + + if (config.isServerEnabled()) { + String host = config.getServerHost(); + int port = config.getServerPort(); + + if (!Strings.isNullOrEmpty(host) && port > 0 && port < 65535) { + args.add("--server"); + args.add(host); + args.add("--port"); + args.add(String.valueOf(port)); + } + } + } + /** * Add window arguments. */