More minor fixes
This commit is contained in:
@ -15,7 +15,7 @@ package org.multimc;/*
|
||||
*/
|
||||
|
||||
import org.multimc.exception.ParseException;
|
||||
import org.multimc.utils.ParamBucket;
|
||||
import org.multimc.utils.Parameters;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.IOException;
|
||||
@ -28,7 +28,7 @@ public final class EntryPoint {
|
||||
|
||||
private static final Logger LOGGER = Logger.getLogger("EntryPoint");
|
||||
|
||||
private final ParamBucket params = new ParamBucket();
|
||||
private final Parameters params = new Parameters();
|
||||
|
||||
private String launcherType;
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
package org.multimc;
|
||||
|
||||
import org.multimc.impl.OneSixLauncher;
|
||||
import org.multimc.utils.ParamBucket;
|
||||
import org.multimc.utils.Parameters;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
@ -15,13 +15,13 @@ public final class LauncherFactory {
|
||||
private LauncherFactory() {
|
||||
launcherRegistry.put("onesix", new LauncherProvider() {
|
||||
@Override
|
||||
public Launcher provide(ParamBucket parameters) {
|
||||
public Launcher provide(Parameters parameters) {
|
||||
return new OneSixLauncher(parameters);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public Launcher createLauncher(String name, ParamBucket parameters) {
|
||||
public Launcher createLauncher(String name, Parameters parameters) {
|
||||
LauncherProvider launcherProvider = launcherRegistry.get(name);
|
||||
|
||||
if (launcherProvider == null)
|
||||
@ -36,7 +36,7 @@ public final class LauncherFactory {
|
||||
|
||||
public interface LauncherProvider {
|
||||
|
||||
Launcher provide(ParamBucket parameters);
|
||||
Launcher provide(Parameters parameters);
|
||||
|
||||
}
|
||||
|
||||
|
@ -23,8 +23,6 @@ import java.awt.event.WindowAdapter;
|
||||
import java.awt.event.WindowEvent;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.net.MalformedURLException;
|
||||
import java.net.URL;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
@ -38,11 +36,15 @@ public final class LegacyFrame extends Frame {
|
||||
|
||||
private static final Logger LOGGER = Logger.getLogger("LegacyFrame");
|
||||
|
||||
private Launcher appletWrap;
|
||||
private final Launcher appletWrap;
|
||||
|
||||
public LegacyFrame(String title) {
|
||||
public LegacyFrame(String title, Applet mcApplet) {
|
||||
super(title);
|
||||
|
||||
appletWrap = new Launcher(mcApplet);
|
||||
|
||||
mcApplet.setStub(appletWrap);
|
||||
|
||||
try {
|
||||
setIconImage(ImageIO.read(new File("icon.png")));
|
||||
} catch (IOException e) {
|
||||
@ -53,7 +55,6 @@ public final class LegacyFrame extends Frame {
|
||||
}
|
||||
|
||||
public void start (
|
||||
Applet mcApplet,
|
||||
String user,
|
||||
String session,
|
||||
int winSizeW,
|
||||
@ -62,14 +63,14 @@ public final class LegacyFrame extends Frame {
|
||||
String serverAddress,
|
||||
String serverPort
|
||||
) {
|
||||
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.
|
||||
Path mpticketFile = Paths.get(System.getProperty("user.dir") + "/../mpticket");
|
||||
Path mpticketFileCorrupt = Paths.get(System.getProperty("user.dir") + "/../mpticket.corrupt");
|
||||
|
||||
Path mpticketFile =
|
||||
Paths.get(System.getProperty("user.dir"), "..", "mpticket");
|
||||
|
||||
Path mpticketFileCorrupt =
|
||||
Paths.get(System.getProperty("user.dir"), "..", "mpticket.corrupt");
|
||||
|
||||
if (Files.exists(mpticketFile)) {
|
||||
try (Scanner fileScanner = new Scanner(
|
||||
@ -115,8 +116,6 @@ public final class LegacyFrame extends Frame {
|
||||
appletWrap.setParameter("demo", "false");
|
||||
appletWrap.setParameter("fullscreen", "false");
|
||||
|
||||
mcApplet.setStub(appletWrap);
|
||||
|
||||
add(appletWrap);
|
||||
|
||||
appletWrap.setPreferredSize(new Dimension(winSizeW, winSizeH));
|
||||
|
@ -18,10 +18,6 @@ package org.multimc.exception;
|
||||
|
||||
public final class ParseException extends IllegalArgumentException {
|
||||
|
||||
public ParseException() {
|
||||
super();
|
||||
}
|
||||
|
||||
public ParseException(String message) {
|
||||
super(message);
|
||||
}
|
||||
|
@ -17,7 +17,7 @@ package org.multimc.impl;
|
||||
|
||||
import org.multimc.Launcher;
|
||||
import org.multimc.applet.LegacyFrame;
|
||||
import org.multimc.utils.ParamBucket;
|
||||
import org.multimc.utils.Parameters;
|
||||
import org.multimc.utils.Utils;
|
||||
|
||||
import java.applet.Applet;
|
||||
@ -55,7 +55,7 @@ public final class OneSixLauncher implements Launcher {
|
||||
|
||||
private final ClassLoader classLoader;
|
||||
|
||||
public OneSixLauncher(ParamBucket params) {
|
||||
public OneSixLauncher(Parameters params) {
|
||||
classLoader = ClassLoader.getSystemClassLoader();
|
||||
|
||||
mcParams = params.allSafe("param", Collections.<String>emptyList());
|
||||
@ -72,22 +72,29 @@ public final class OneSixLauncher implements Launcher {
|
||||
|
||||
cwd = System.getProperty("user.dir");
|
||||
|
||||
String windowParams = params.firstSafe("windowParams", "854x480");
|
||||
String windowParams = params.firstSafe("windowParams", null);
|
||||
|
||||
String[] dimStrings = windowParams.split("x");
|
||||
if (windowParams != null) {
|
||||
String[] dimStrings = windowParams.split("x");
|
||||
|
||||
if (windowParams.equalsIgnoreCase("max")) {
|
||||
maximize = true;
|
||||
if (windowParams.equalsIgnoreCase("max")) {
|
||||
maximize = true;
|
||||
|
||||
winSizeW = DEFAULT_WINDOW_WIDTH;
|
||||
winSizeH = DEFAULT_WINDOW_HEIGHT;
|
||||
} else if (dimStrings.length == 2) {
|
||||
maximize = false;
|
||||
|
||||
winSizeW = Integer.parseInt(dimStrings[0]);
|
||||
winSizeH = Integer.parseInt(dimStrings[1]);
|
||||
} else {
|
||||
throw new IllegalArgumentException("Unexpected window size parameter value: " + windowParams);
|
||||
}
|
||||
} else {
|
||||
maximize = false;
|
||||
|
||||
winSizeW = DEFAULT_WINDOW_WIDTH;
|
||||
winSizeH = DEFAULT_WINDOW_HEIGHT;
|
||||
} else if (dimStrings.length == 2) {
|
||||
maximize = false;
|
||||
|
||||
winSizeW = Integer.parseInt(dimStrings[0]);
|
||||
winSizeH = Integer.parseInt(dimStrings[1]);
|
||||
} else {
|
||||
throw new IllegalArgumentException("Unexpected window size parameter value: " + windowParams);
|
||||
}
|
||||
}
|
||||
|
||||
@ -121,10 +128,9 @@ public final class OneSixLauncher implements Launcher {
|
||||
|
||||
Applet mcApplet = (Applet) mcAppletClass.getConstructor().newInstance();
|
||||
|
||||
LegacyFrame mcWindow = new LegacyFrame(windowTitle);
|
||||
LegacyFrame mcWindow = new LegacyFrame(windowTitle, mcApplet);
|
||||
|
||||
mcWindow.start(
|
||||
mcApplet,
|
||||
userName,
|
||||
sessionId,
|
||||
winSizeW,
|
||||
|
@ -23,7 +23,7 @@ import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public final class ParamBucket {
|
||||
public final class Parameters {
|
||||
|
||||
private final Map<String, List<String>> paramsMap = new HashMap<>();
|
||||
|
Reference in New Issue
Block a user