@ -54,10 +54,6 @@
|
||||
|
||||
package org.prismlauncher;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.InputStreamReader;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
|
||||
import org.prismlauncher.exception.ParseException;
|
||||
import org.prismlauncher.launcher.Launcher;
|
||||
import org.prismlauncher.launcher.impl.StandardLauncher;
|
||||
@ -65,8 +61,11 @@ import org.prismlauncher.launcher.impl.legacy.LegacyLauncher;
|
||||
import org.prismlauncher.utils.Parameters;
|
||||
import org.prismlauncher.utils.logging.Log;
|
||||
|
||||
public final class EntryPoint {
|
||||
import java.io.BufferedReader;
|
||||
import java.io.InputStreamReader;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
|
||||
public final class EntryPoint {
|
||||
public static void main(String[] args) {
|
||||
ExitCode code = listen();
|
||||
|
||||
@ -160,19 +159,18 @@ public final class EntryPoint {
|
||||
return PreLaunchAction.PROCEED;
|
||||
}
|
||||
|
||||
private enum PreLaunchAction {
|
||||
PROCEED, LAUNCH, ABORT
|
||||
}
|
||||
private enum PreLaunchAction { PROCEED, LAUNCH, ABORT }
|
||||
|
||||
private enum ExitCode {
|
||||
NORMAL(0), ABORT(1), ERROR(2), ILLEGAL_ARGUMENT(65);
|
||||
NORMAL(0),
|
||||
ABORT(1),
|
||||
ERROR(2),
|
||||
ILLEGAL_ARGUMENT(65);
|
||||
|
||||
private final int numeric;
|
||||
|
||||
ExitCode(int numeric) {
|
||||
this.numeric = numeric;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -38,11 +38,9 @@
|
||||
package org.prismlauncher.exception;
|
||||
|
||||
public final class ParameterNotFoundException extends IllegalArgumentException {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
public ParameterNotFoundException(String key) {
|
||||
super(String.format("Required parameter '%s' was not found", key));
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -38,11 +38,9 @@
|
||||
package org.prismlauncher.exception;
|
||||
|
||||
public final class ParseException extends IllegalArgumentException {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
public ParseException(String input, String format) {
|
||||
super(String.format("For input '%s' - should match '%s'", input, format));
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -38,7 +38,5 @@
|
||||
package org.prismlauncher.launcher;
|
||||
|
||||
public interface Launcher {
|
||||
|
||||
void launch() throws Throwable;
|
||||
|
||||
}
|
||||
|
@ -54,15 +54,14 @@
|
||||
|
||||
package org.prismlauncher.launcher.impl;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.prismlauncher.exception.ParseException;
|
||||
import org.prismlauncher.launcher.Launcher;
|
||||
import org.prismlauncher.utils.Parameters;
|
||||
|
||||
public abstract class AbstractLauncher implements Launcher {
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public abstract class AbstractLauncher implements Launcher {
|
||||
private static final int DEFAULT_WINDOW_WIDTH = 854, DEFAULT_WINDOW_HEIGHT = 480;
|
||||
|
||||
// parameters, separated from ParamBucket
|
||||
@ -106,5 +105,4 @@ public abstract class AbstractLauncher implements Launcher {
|
||||
throw new ParseException(windowParams, "[width]x[height]");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -54,13 +54,12 @@
|
||||
|
||||
package org.prismlauncher.launcher.impl;
|
||||
|
||||
import java.lang.invoke.MethodHandle;
|
||||
|
||||
import org.prismlauncher.utils.Parameters;
|
||||
import org.prismlauncher.utils.ReflectionUtils;
|
||||
|
||||
public final class StandardLauncher extends AbstractLauncher {
|
||||
import java.lang.invoke.MethodHandle;
|
||||
|
||||
public final class StandardLauncher extends AbstractLauncher {
|
||||
public StandardLauncher(Parameters params) {
|
||||
super(params);
|
||||
}
|
||||
@ -87,5 +86,4 @@ public final class StandardLauncher extends AbstractLauncher {
|
||||
MethodHandle method = ReflectionUtils.findMainMethod(mainClassName);
|
||||
method.invokeExact(gameArgs.toArray(new String[0]));
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -54,6 +54,8 @@
|
||||
|
||||
package org.prismlauncher.launcher.impl.legacy;
|
||||
|
||||
import org.prismlauncher.utils.logging.Log;
|
||||
|
||||
import java.applet.Applet;
|
||||
import java.awt.Dimension;
|
||||
import java.awt.event.WindowAdapter;
|
||||
@ -70,12 +72,9 @@ import java.util.List;
|
||||
import javax.imageio.ImageIO;
|
||||
import javax.swing.JFrame;
|
||||
|
||||
import org.prismlauncher.utils.logging.Log;
|
||||
|
||||
import net.minecraft.Launcher;
|
||||
|
||||
public final class LegacyFrame extends JFrame {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private final Launcher launcher;
|
||||
@ -96,8 +95,8 @@ public final class LegacyFrame extends JFrame {
|
||||
addWindowListener(new ForceExitHandler());
|
||||
}
|
||||
|
||||
public void start(String user, String session, int width, int height, boolean maximize, String serverAddress,
|
||||
String serverPort, boolean demo) {
|
||||
public void start(
|
||||
String user, String session, int width, int height, boolean maximize, String serverAddress, String serverPort, boolean demo) {
|
||||
// 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.
|
||||
@ -157,7 +156,6 @@ public final class LegacyFrame extends JFrame {
|
||||
}
|
||||
|
||||
private final class ForceExitHandler extends WindowAdapter {
|
||||
|
||||
@Override
|
||||
public void windowClosing(WindowEvent event) {
|
||||
// FIXME better solution
|
||||
@ -184,7 +182,5 @@ public final class LegacyFrame extends JFrame {
|
||||
// old minecraft versions can hang without this >_<
|
||||
System.exit(0);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -55,22 +55,21 @@
|
||||
|
||||
package org.prismlauncher.launcher.impl.legacy;
|
||||
|
||||
import org.prismlauncher.launcher.impl.AbstractLauncher;
|
||||
import org.prismlauncher.utils.Parameters;
|
||||
import org.prismlauncher.utils.ReflectionUtils;
|
||||
import org.prismlauncher.utils.logging.Log;
|
||||
|
||||
import java.io.File;
|
||||
import java.lang.invoke.MethodHandle;
|
||||
import java.lang.reflect.Field;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import org.prismlauncher.launcher.impl.AbstractLauncher;
|
||||
import org.prismlauncher.utils.Parameters;
|
||||
import org.prismlauncher.utils.ReflectionUtils;
|
||||
import org.prismlauncher.utils.logging.Log;
|
||||
|
||||
/**
|
||||
* Used to launch old versions that support applets.
|
||||
*/
|
||||
public final class LegacyLauncher extends AbstractLauncher {
|
||||
|
||||
private final String user, session;
|
||||
private final String title;
|
||||
private final String appletClass;
|
||||
@ -109,8 +108,7 @@ public final class LegacyLauncher extends AbstractLauncher {
|
||||
try {
|
||||
LegacyFrame window = new LegacyFrame(title, ReflectionUtils.createAppletClass(appletClass));
|
||||
|
||||
window.start(user, session, width, height, maximize, serverAddress, serverPort,
|
||||
gameArgs.contains("--demo"));
|
||||
window.start(user, session, width, height, maximize, serverAddress, serverPort, gameArgs.contains("--demo"));
|
||||
return;
|
||||
} catch (Throwable e) {
|
||||
Log.error("Running applet wrapper failed with exception; falling back to main class", e);
|
||||
@ -122,5 +120,4 @@ public final class LegacyLauncher extends AbstractLauncher {
|
||||
MethodHandle method = ReflectionUtils.findMainMethod(main);
|
||||
method.invokeExact(gameArgs.toArray(new String[0]));
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -54,15 +54,14 @@
|
||||
|
||||
package org.prismlauncher.utils;
|
||||
|
||||
import org.prismlauncher.exception.ParameterNotFoundException;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.prismlauncher.exception.ParameterNotFoundException;
|
||||
|
||||
public final class Parameters {
|
||||
|
||||
private final Map<String, List<String>> map = new HashMap<>();
|
||||
|
||||
public void add(String key, String value) {
|
||||
@ -112,5 +111,4 @@ public final class Parameters {
|
||||
|
||||
return params.get(0);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -54,6 +54,8 @@
|
||||
|
||||
package org.prismlauncher.utils;
|
||||
|
||||
import org.prismlauncher.utils.logging.Log;
|
||||
|
||||
import java.applet.Applet;
|
||||
import java.io.File;
|
||||
import java.lang.invoke.MethodHandle;
|
||||
@ -62,10 +64,7 @@ import java.lang.invoke.MethodType;
|
||||
import java.lang.reflect.Field;
|
||||
import java.lang.reflect.Modifier;
|
||||
|
||||
import org.prismlauncher.utils.logging.Log;
|
||||
|
||||
public final class ReflectionUtils {
|
||||
|
||||
private static final MethodHandles.Lookup LOOKUP = MethodHandles.lookup();
|
||||
private static final ClassLoader LOADER = ClassLoader.getSystemClassLoader();
|
||||
|
||||
@ -146,9 +145,7 @@ public final class ReflectionUtils {
|
||||
* @throws NoSuchMethodException
|
||||
* @throws IllegalAccessException
|
||||
*/
|
||||
public static MethodHandle findMainMethod(String clazz)
|
||||
throws ClassNotFoundException, NoSuchMethodException, IllegalAccessException {
|
||||
public static MethodHandle findMainMethod(String clazz) throws ClassNotFoundException, NoSuchMethodException, IllegalAccessException {
|
||||
return findMainMethod(LOADER.loadClass(clazz));
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -55,5 +55,4 @@ public enum Level {
|
||||
this.name = name;
|
||||
this.stderr = stderr;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -43,9 +43,8 @@ import java.io.PrintStream;
|
||||
* messages.
|
||||
*/
|
||||
public final class Log {
|
||||
|
||||
// original before possibly overridden by MC
|
||||
private static final PrintStream OUT = new PrintStream(System.out), ERR = new PrintStream(System.err);
|
||||
private static final PrintStream OUT = new PrintStream(System.out), ERR = new PrintStream(System.err);
|
||||
private static final boolean DEBUG = Boolean.getBoolean("org.prismlauncher.debug");
|
||||
|
||||
public static void launcher(String message) {
|
||||
@ -100,5 +99,4 @@ public final class Log {
|
||||
else
|
||||
OUT.println(message);
|
||||
}
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user