Attempt to mimic clang-format
Signed-off-by: TheKodeToad <TheKodeToad@proton.me>
This commit is contained in:
@ -80,7 +80,8 @@ public abstract class AbstractLauncher implements Launcher {
|
||||
|
||||
protected final String mainClassName;
|
||||
|
||||
protected AbstractLauncher(Parameters params) {
|
||||
protected AbstractLauncher(Parameters params)
|
||||
{
|
||||
this.mcParams = Collections.unmodifiableList(params.getList("param", new ArrayList<String>()));
|
||||
this.mainClassName = params.getString("mainClass", "net.minecraft.client.Minecraft");
|
||||
|
||||
@ -99,10 +100,12 @@ public abstract class AbstractLauncher implements Launcher {
|
||||
this.width = Integer.parseInt(sizePair[0]);
|
||||
this.height = Integer.parseInt(sizePair[1]);
|
||||
} catch (NumberFormatException e) {
|
||||
throw new ParseException(String.format("Could not parse window parameters from '%s'", windowParams), e);
|
||||
throw new ParseException(String.format("Could not parse window parameters from '%s'", windowParams),
|
||||
e);
|
||||
}
|
||||
} else {
|
||||
throw new ParseException(String.format("Invalid window size parameters '%s'. Format: [height]x[width]", windowParams));
|
||||
throw new ParseException(
|
||||
String.format("Invalid window size parameters '%s'. Format: [height]x[width]", windowParams));
|
||||
}
|
||||
} else {
|
||||
this.width = DEFAULT_WINDOW_WIDTH;
|
||||
|
@ -66,16 +66,13 @@ import java.util.List;
|
||||
|
||||
public final class StandardLauncher extends AbstractLauncher {
|
||||
|
||||
public StandardLauncher(Parameters params) {
|
||||
super(params);
|
||||
}
|
||||
public StandardLauncher(Parameters params) { super(params); }
|
||||
|
||||
public static LauncherProvider getProvider() {
|
||||
return new StandardLauncherProvider();
|
||||
}
|
||||
public static LauncherProvider getProvider() { return new StandardLauncherProvider(); }
|
||||
|
||||
@Override
|
||||
public void launch() throws Throwable {
|
||||
public void launch() throws Throwable
|
||||
{
|
||||
// window size, title and state
|
||||
|
||||
// FIXME: there is no good way to maximize the minecraft window from here.
|
||||
@ -104,9 +101,7 @@ public final class StandardLauncher extends AbstractLauncher {
|
||||
|
||||
private static class StandardLauncherProvider implements LauncherProvider {
|
||||
@Override
|
||||
public Launcher provide(Parameters parameters) {
|
||||
return new StandardLauncher(parameters);
|
||||
}
|
||||
public Launcher provide(Parameters parameters) { return new StandardLauncher(parameters); }
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -82,7 +82,8 @@ public final class LegacyFrame extends Frame /* TODO consider JFrame */ {
|
||||
|
||||
private final Launcher launcher;
|
||||
|
||||
public LegacyFrame(String title, Applet applet) {
|
||||
public LegacyFrame(String title, Applet applet)
|
||||
{
|
||||
super(title);
|
||||
|
||||
launcher = new Launcher(applet);
|
||||
@ -98,35 +99,24 @@ public final class LegacyFrame extends Frame /* TODO consider JFrame */ {
|
||||
addWindowListener(new ForceExitHandler());
|
||||
}
|
||||
|
||||
public void start (
|
||||
String user,
|
||||
String session,
|
||||
int width,
|
||||
int height,
|
||||
boolean maximize,
|
||||
String serverAddress,
|
||||
String serverPort,
|
||||
boolean isDemo
|
||||
) {
|
||||
// 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.
|
||||
public void start(String user, String session, int width, int height, boolean maximize, String serverAddress,
|
||||
String serverPort, boolean isDemo)
|
||||
{
|
||||
// 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 mpticketFile = Paths.get(System.getProperty("user.dir"), "..", "mpticket");
|
||||
|
||||
Path mpticketFileCorrupt =
|
||||
Paths.get(System.getProperty("user.dir"), "..", "mpticket.corrupt");
|
||||
Path mpticketFileCorrupt = Paths.get(System.getProperty("user.dir"), "..", "mpticket.corrupt");
|
||||
|
||||
if (Files.exists(mpticketFile)) {
|
||||
try {
|
||||
List<String> lines = Files.readAllLines(mpticketFile, StandardCharsets.UTF_8);
|
||||
|
||||
if (lines.size() < 3) {
|
||||
Files.move(
|
||||
mpticketFile,
|
||||
mpticketFileCorrupt,
|
||||
StandardCopyOption.REPLACE_EXISTING
|
||||
);
|
||||
Files.move(mpticketFile, mpticketFileCorrupt, StandardCopyOption.REPLACE_EXISTING);
|
||||
|
||||
LOGGER.warning("Mpticket file is corrupted!");
|
||||
} else {
|
||||
@ -175,10 +165,12 @@ public final class LegacyFrame extends Frame /* TODO consider JFrame */ {
|
||||
private final class ForceExitHandler extends WindowAdapter {
|
||||
|
||||
@Override
|
||||
public void windowClosing(WindowEvent event) {
|
||||
public void windowClosing(WindowEvent event)
|
||||
{
|
||||
new Thread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
public void run()
|
||||
{
|
||||
try {
|
||||
Thread.sleep(30000L);
|
||||
} catch (InterruptedException e) {
|
||||
|
@ -83,7 +83,8 @@ public final class LegacyLauncher extends AbstractLauncher {
|
||||
private final boolean usesApplet;
|
||||
private final String cwd;
|
||||
|
||||
public LegacyLauncher(Parameters params) {
|
||||
public LegacyLauncher(Parameters params)
|
||||
{
|
||||
super(params);
|
||||
|
||||
user = params.getString("userName");
|
||||
@ -97,12 +98,11 @@ public final class LegacyLauncher extends AbstractLauncher {
|
||||
cwd = System.getProperty("user.dir");
|
||||
}
|
||||
|
||||
public static LauncherProvider getProvider() {
|
||||
return new LegacyLauncherProvider();
|
||||
}
|
||||
public static LauncherProvider getProvider() { return new LegacyLauncherProvider(); }
|
||||
|
||||
@Override
|
||||
public void launch() throws Throwable {
|
||||
public void launch() throws Throwable
|
||||
{
|
||||
Class<?> main = ClassLoader.getSystemClassLoader().loadClass(this.mainClassName);
|
||||
Field gameDirField = ReflectionUtils.getMinecraftGameDirField(main);
|
||||
|
||||
@ -119,13 +119,8 @@ public final class LegacyLauncher extends AbstractLauncher {
|
||||
try {
|
||||
LegacyFrame window = new LegacyFrame(title, ReflectionUtils.createAppletClass(this.appletClass));
|
||||
|
||||
window.start(
|
||||
this.user,
|
||||
this.session,
|
||||
this.width, this.height, this.maximize,
|
||||
this.serverAddress, this.serverPort,
|
||||
this.mcParams.contains("--demo")
|
||||
);
|
||||
window.start(this.user, this.session, this.width, this.height, this.maximize, this.serverAddress,
|
||||
this.serverPort, this.mcParams.contains("--demo"));
|
||||
} catch (Throwable e) {
|
||||
LOGGER.log(Level.SEVERE, "Running applet wrapper failed with exception; falling back to main class", e);
|
||||
}
|
||||
@ -137,9 +132,7 @@ public final class LegacyLauncher extends AbstractLauncher {
|
||||
|
||||
private static class LegacyLauncherProvider implements LauncherProvider {
|
||||
@Override
|
||||
public Launcher provide(Parameters parameters) {
|
||||
return new LegacyLauncher(parameters);
|
||||
}
|
||||
public Launcher provide(Parameters parameters) { return new LegacyLauncher(parameters); }
|
||||
}
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user