summaryrefslogtreecommitdiffstats
path: root/libraries
diff options
context:
space:
mode:
authorMinecraftZuriki <33717810+MinecraftZuriki@users.noreply.github.com>2017-11-17 02:19:41 +1100
committerMinecraftZuriki <zuriki.stuff@googlemail.com>2017-11-18 01:27:57 +1100
commit3470158943acb9fc4439ea255fe3ea0fbc7dbc85 (patch)
treeb10b68c64d6a06917c91536e0d083aa33121d57c /libraries
parentb000b336615030b1c6889b1adf0703d06a163550 (diff)
downloadMultiMC-3470158943acb9fc4439ea255fe3ea0fbc7dbc85.tar
MultiMC-3470158943acb9fc4439ea255fe3ea0fbc7dbc85.tar.gz
MultiMC-3470158943acb9fc4439ea255fe3ea0fbc7dbc85.tar.lz
MultiMC-3470158943acb9fc4439ea255fe3ea0fbc7dbc85.tar.xz
MultiMC-3470158943acb9fc4439ea255fe3ea0fbc7dbc85.zip
Support for classic multiplayer via mpticket
Diffstat (limited to 'libraries')
-rw-r--r--libraries/launcher/org/multimc/LegacyFrame.java51
1 files changed, 49 insertions, 2 deletions
diff --git a/libraries/launcher/org/multimc/LegacyFrame.java b/libraries/launcher/org/multimc/LegacyFrame.java
index 8883f424..c9ee6aad 100644
--- a/libraries/launcher/org/multimc/LegacyFrame.java
+++ b/libraries/launcher/org/multimc/LegacyFrame.java
@@ -23,9 +23,12 @@ import java.awt.event.WindowEvent;
import java.awt.event.WindowListener;
import java.awt.image.BufferedImage;
import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
import java.io.IOException;
import java.net.MalformedURLException;
import java.net.URL;
+import java.util.Scanner;
public class LegacyFrame extends Frame implements WindowListener
{
@@ -48,12 +51,56 @@ public class LegacyFrame extends Frame implements WindowListener
try {
appletWrap = new Launcher( mcApplet, new URL ( "http://www.minecraft.net/game" ) );
} catch ( MalformedURLException ignored ) {}
+
+ // Implements support for launching in to multiplayer on classic servers using a mpticket
+ // file generated by an external program and stored in the instance's root folder.
+ File mpticketFile = null;
+ Scanner fileReader = null;
+ try {
+ mpticketFile = new File(System.getProperty("user.dir") + "/../mpticket").getCanonicalFile();
+ fileReader = new Scanner(new FileInputStream(mpticketFile), "ascii");
+ String[] mpticketParams = new String[3];
+
+ for(int i=0;i<3;i++) {
+ if(fileReader.hasNextLine()) {
+ mpticketParams[i] = fileReader.nextLine();
+ } else {
+ throw new IllegalArgumentException();
+ }
+ }
+
+ // Assumes parameters are valid and in the correct order
+ appletWrap.setParameter("server", mpticketParams[0]);
+ appletWrap.setParameter("port", mpticketParams[1]);
+ appletWrap.setParameter("mppass", mpticketParams[2]);
+
+ fileReader.close();
+ mpticketFile.delete();
+ }
+ catch (FileNotFoundException e) {}
+ catch (IllegalArgumentException e) {
+
+ fileReader.close();
+ File mpticketFileCorrupt = new File(System.getProperty("user.dir") + "/../mpticket.corrupt");
+ if(mpticketFileCorrupt.exists()) {
+ mpticketFileCorrupt.delete();
+ }
+ mpticketFile.renameTo(mpticketFileCorrupt);
+
+ System.err.println("Malformed mpticket file, missing argument.");
+ e.printStackTrace(System.err);
+ System.exit(-1);
+ }
+ catch (Exception e) {
+ e.printStackTrace(System.err);
+ System.exit(-1);
+ }
appletWrap.setParameter ( "username", user );
appletWrap.setParameter ( "sessionid", session );
appletWrap.setParameter ( "stand-alone", "true" ); // Show the quit button.
appletWrap.setParameter ( "haspaid", "true" ); // Some old versions need this for world saves to work.
- appletWrap.setParameter ( "demo", "false" );
- appletWrap.setParameter("fullscreen", "false");
+ appletWrap.setParameter ( "demo", "false" );
+ appletWrap.setParameter ( "fullscreen", "false" );
mcApplet.setStub(appletWrap);
this.add ( appletWrap );
appletWrap.setPreferredSize ( new Dimension (winSizeW, winSizeH) );