Skip to content

Commit

Permalink
Merge pull request #215 from me4502/master
Browse files Browse the repository at this point in the history
Add argument to configuration for auto-joining a server.
  • Loading branch information
sk89q authored Nov 11, 2017
2 parents 768f7a5 + 21e6732 commit 403f284
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
20 changes: 20 additions & 0 deletions launcher/src/main/java/com/skcraft/launcher/launch/Runner.java
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,7 @@ public Process call() throws Exception {
addLibraries();
addJarArgs();
addProxyArgs();
addServerArgs();
addWindowArgs();
addPlatformArgs();
addLegacyArgs();
Expand Down Expand Up @@ -305,6 +306,25 @@ private void addProxyArgs() {
}
}

/**
* Add server arguments.
*/
private void addServerArgs() {
List<String> 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.
*/
Expand Down

0 comments on commit 403f284

Please sign in to comment.