diff --git a/api/logic/minecraft/MinecraftInstance.cpp b/api/logic/minecraft/MinecraftInstance.cpp index e426d5c42..54c7f5945 100644 --- a/api/logic/minecraft/MinecraftInstance.cpp +++ b/api/logic/minecraft/MinecraftInstance.cpp @@ -474,8 +474,17 @@ QString MinecraftInstance::createLaunchScript(AuthSessionPtr session, MinecraftS launchScript += "appletClass " + appletClass + "\n"; } + if (serverToJoin && !serverToJoin->address.isEmpty()) + { + launchScript += "serverAddress " + serverToJoin->address + "\n"; + launchScript += "serverPort " + QString::number(serverToJoin->port) + "\n"; + } + // generic minecraft params - for (auto param : processMinecraftArgs(session, serverToJoin)) + for (auto param : processMinecraftArgs( + session, + nullptr /* When using a launch script, the server parameters are handled by it*/ + )) { launchScript += "param " + param + "\n"; } diff --git a/libraries/launcher/org/multimc/LegacyFrame.java b/libraries/launcher/org/multimc/LegacyFrame.java index c72c053e1..985a10e6a 100644 --- a/libraries/launcher/org/multimc/LegacyFrame.java +++ b/libraries/launcher/org/multimc/LegacyFrame.java @@ -46,7 +46,16 @@ public class LegacyFrame extends Frame implements WindowListener this.addWindowListener ( this ); } - public void start ( Applet mcApplet, String user, String session, int winSizeW, int winSizeH, boolean maximize ) + public void start ( + Applet mcApplet, + String user, + String session, + int winSizeW, + int winSizeH, + boolean maximize, + String serverAddress, + String serverPort + ) { try { appletWrap = new Launcher( mcApplet, new URL ( "http://www.minecraft.net/game" ) ); @@ -95,6 +104,13 @@ public class LegacyFrame extends Frame implements WindowListener e.printStackTrace(System.err); System.exit(-1); } + + if (serverAddress != null) + { + appletWrap.setParameter("server", serverAddress); + appletWrap.setParameter("port", serverPort); + } + appletWrap.setParameter ( "username", user ); appletWrap.setParameter ( "sessionid", session ); appletWrap.setParameter ( "stand-alone", "true" ); // Show the quit button. diff --git a/libraries/launcher/org/multimc/onesix/OneSixLauncher.java b/libraries/launcher/org/multimc/onesix/OneSixLauncher.java index b6b384ab4..ea445995e 100644 --- a/libraries/launcher/org/multimc/onesix/OneSixLauncher.java +++ b/libraries/launcher/org/multimc/onesix/OneSixLauncher.java @@ -47,6 +47,9 @@ public class OneSixLauncher implements Launcher private boolean maximize; private String cwd; + private String serverAddress; + private String serverPort; + // the much abused system classloader, for convenience (for further abuse) private ClassLoader cl; @@ -64,6 +67,9 @@ public class OneSixLauncher implements Launcher windowTitle = params.firstSafe("windowTitle", "Minecraft"); windowParams = params.firstSafe("windowParams", "854x480"); + serverAddress = params.firstSafe("serverAddress", null); + serverPort = params.firstSafe("serverPort", null); + cwd = System.getProperty("user.dir"); winSizeW = 854; @@ -122,7 +128,7 @@ public class OneSixLauncher implements Launcher Class MCAppletClass = cl.loadClass(appletClass); Applet mcappl = (Applet) MCAppletClass.newInstance(); LegacyFrame mcWindow = new LegacyFrame(windowTitle); - mcWindow.start(mcappl, userName, sessionId, winSizeW, winSizeH, maximize); + mcWindow.start(mcappl, userName, sessionId, winSizeW, winSizeH, maximize, serverAddress, serverPort); return 0; } catch (Exception e) { @@ -164,6 +170,14 @@ public class OneSixLauncher implements Launcher mcparams.add(Integer.toString(winSizeH)); } + if (serverAddress != null) + { + mcparams.add("--server"); + mcparams.add(serverAddress); + mcparams.add("--port"); + mcparams.add(serverPort); + } + // Get the Minecraft Class. Class mc; try