NOISSUE Make LauncherPart aware of server to join

This commit is contained in:
Janrupf 2021-05-22 16:32:15 +02:00
parent 23a706bbae
commit 0ccd7223fd
3 changed files with 42 additions and 3 deletions

View File

@ -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";
}

View File

@ -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.

View File

@ -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