Always use this for consistency

Signed-off-by: TheKodeToad <TheKodeToad@proton.me>
This commit is contained in:
TheKodeToad 2022-11-05 09:10:52 +00:00
parent d90eff64d0
commit 50d40257fe
5 changed files with 69 additions and 69 deletions

View File

@ -113,28 +113,28 @@ public final class Launcher extends Applet implements AppletStub {
wrappedApplet = applet;
applet.setStub(this);
applet.setSize(getWidth(), getHeight());
applet.setSize(this.getWidth(), this.getHeight());
setLayout(new BorderLayout());
this.add(applet, "Center");
applet.init();
active = true;
this.active = true;
applet.start();
validate();
this.validate();
}
@Override
public boolean isActive() {
return active;
return this.active;
}
@Override
public URL getDocumentBase() {
return documentBase;
return this.documentBase;
}
@Override
@ -149,7 +149,7 @@ public final class Launcher extends Applet implements AppletStub {
@Override
public String getParameter(String name) {
String param = params.get(name);
String param = this.params.get(name);
if (param != null)
return param;
@ -164,49 +164,49 @@ public final class Launcher extends Applet implements AppletStub {
@Override
public void resize(int width, int height) {
wrappedApplet.resize(width, height);
this.wrappedApplet.resize(width, height);
}
@Override
public void resize(Dimension size) {
wrappedApplet.resize(size);
this.wrappedApplet.resize(size);
}
@Override
public void init() {
if (wrappedApplet != null)
wrappedApplet.init();
if (this.wrappedApplet != null)
this.wrappedApplet.init();
}
@Override
public void start() {
wrappedApplet.start();
this.wrappedApplet.start();
active = true;
this.active = true;
}
@Override
public void stop() {
wrappedApplet.stop();
this.wrappedApplet.stop();
active = false;
this.active = false;
}
@Override
public void destroy() {
wrappedApplet.destroy();
this.wrappedApplet.destroy();
}
@Override
public void appletResize(int width, int height) {
wrappedApplet.resize(width, height);
this.wrappedApplet.resize(width, height);
}
@Override
public void setVisible(boolean visible) {
super.setVisible(visible);
wrappedApplet.setVisible(visible);
this.wrappedApplet.setVisible(visible);
}
@Override
@ -218,7 +218,7 @@ public final class Launcher extends Applet implements AppletStub {
}
public void setParameter(String name, String value) {
params.put(name, value);
this.params.put(name, value);
}
}

View File

@ -75,21 +75,21 @@ public final class StandardLauncher extends AbstractLauncher {
// mcparams.add("--fullscreen");
if (!this.maximize) {
mcParams.add("--width");
mcParams.add(Integer.toString(width));
mcParams.add("--height");
mcParams.add(Integer.toString(height));
this.mcParams.add("--width");
this.mcParams.add(Integer.toString(this.width));
this.mcParams.add("--height");
this.mcParams.add(Integer.toString(this.height));
}
if (this.serverAddress != null) {
mcParams.add("--server");
mcParams.add(serverAddress);
mcParams.add("--port");
mcParams.add(serverPort);
this.mcParams.add("--server");
this.mcParams.add(this.serverAddress);
this.mcParams.add("--port");
this.mcParams.add(this.serverPort);
}
MethodHandle method = ReflectionUtils.findMainMethod(this.mainClassName);
method.invokeExact(mcParams.toArray(new String[0]));
method.invokeExact(this.mcParams.toArray(new String[0]));
}
}

View File

@ -85,17 +85,17 @@ public final class LegacyFrame extends JFrame {
public LegacyFrame(String title, Applet applet) {
super(title);
launcher = new Launcher(applet);
this.launcher = new Launcher(applet);
applet.setStub(launcher);
applet.setStub(this.launcher);
try {
setIconImage(ImageIO.read(new File("icon.png")));
this.setIconImage(ImageIO.read(new File("icon.png")));
} catch (IOException e) {
LOGGER.log(Level.WARNING, "Unable to read Minecraft icon", e);
}
addWindowListener(new ForceExitHandler());
this.addWindowListener(new ForceExitHandler());
}
public void start(String user, String session, int width, int height, boolean maximize, String serverAddress,
@ -119,9 +119,9 @@ public final class LegacyFrame extends JFrame {
LOGGER.warning("Mpticket file is corrupted!");
} else {
// Assumes parameters are valid and in the correct order
launcher.setParameter("server", lines.get(0));
launcher.setParameter("port", lines.get(1));
launcher.setParameter("mppass", lines.get(2));
this.launcher.setParameter("server", lines.get(0));
this.launcher.setParameter("port", lines.get(1));
this.launcher.setParameter("mppass", lines.get(2));
}
} catch (IOException e) {
LOGGER.log(Level.WARNING, "Unable to read mpticket file!", e);
@ -129,35 +129,35 @@ public final class LegacyFrame extends JFrame {
}
if (serverAddress != null) {
launcher.setParameter("server", serverAddress);
launcher.setParameter("port", serverPort);
this.launcher.setParameter("server", serverAddress);
this.launcher.setParameter("port", serverPort);
}
launcher.setParameter("username", user);
launcher.setParameter("sessionid", session);
launcher.setParameter("stand-alone", "true"); // Show the quit button. TODO: why won't this work?
launcher.setParameter("haspaid", "true"); // Some old versions need this for world saves to work.
launcher.setParameter("demo", isDemo ? "true" : "false");
launcher.setParameter("fullscreen", "false");
this.launcher.setParameter("username", user);
this.launcher.setParameter("sessionid", session);
this.launcher.setParameter("stand-alone", "true"); // Show the quit button. TODO: why won't this work?
this.launcher.setParameter("haspaid", "true"); // Some old versions need this for world saves to work.
this.launcher.setParameter("demo", isDemo ? "true" : "false");
this.launcher.setParameter("fullscreen", "false");
add(launcher);
this.add(this.launcher);
launcher.setPreferredSize(new Dimension(width, height));
this.launcher.setPreferredSize(new Dimension(width, height));
pack();
this.pack();
setLocationRelativeTo(null);
setResizable(true);
this.setLocationRelativeTo(null);
this.setResizable(true);
if (maximize)
setExtendedState(MAXIMIZED_BOTH);
validate();
this.validate();
launcher.init();
launcher.start();
this.launcher.init();
this.launcher.start();
setVisible(true);
this.setVisible(true);
}
private final class ForceExitHandler extends WindowAdapter {
@ -179,9 +179,9 @@ public final class LegacyFrame extends JFrame {
}
}).start();
if (launcher != null) {
launcher.stop();
launcher.destroy();
if (LegacyFrame.this.launcher != null) {
LegacyFrame.this.launcher.stop();
LegacyFrame.this.launcher.destroy();
}
// old minecraft versions can hang without this >_<

View File

@ -84,15 +84,15 @@ public final class LegacyLauncher extends AbstractLauncher {
public LegacyLauncher(Parameters params) {
super(params);
user = params.getString("userName");
session = params.getString("sessionId");
title = params.getString("windowTitle", "Minecraft");
appletClass = params.getString("appletClass", "net.minecraft.client.MinecraftApplet");
this.user = params.getString("userName");
this.session = params.getString("sessionId");
this.title = params.getString("windowTitle", "Minecraft");
this.appletClass = params.getString("appletClass", "net.minecraft.client.MinecraftApplet");
List<String> traits = params.getList("traits", Collections.<String>emptyList());
usesApplet = !traits.contains("noapplet");
this.usesApplet = !traits.contains("noapplet");
cwd = System.getProperty("user.dir");
this.cwd = System.getProperty("user.dir");
}
@Override
@ -104,14 +104,14 @@ public final class LegacyLauncher extends AbstractLauncher {
LOGGER.warning("Could not find Minecraft path field");
else {
gameDirField.setAccessible(true);
gameDirField.set(null /* field is static, so instance is null */, new File(cwd));
gameDirField.set(null /* field is static, so instance is null */, new File(this.cwd));
}
if (this.usesApplet) {
LOGGER.info("Launching legacy minecraft using applet wrapper...");
try {
LegacyFrame window = new LegacyFrame(title, ReflectionUtils.createAppletClass(this.appletClass));
LegacyFrame window = new LegacyFrame(this.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"));
@ -123,7 +123,7 @@ public final class LegacyLauncher extends AbstractLauncher {
}
MethodHandle method = ReflectionUtils.findMainEntrypoint(main);
method.invokeExact(mcParams.toArray(new String[0]));
method.invokeExact(this.mcParams.toArray(new String[0]));
}
}

View File

@ -67,19 +67,19 @@ public final class Parameters {
private final Map<String, List<String>> map = new HashMap<>();
public void add(String key, String value) {
List<String> params = map.get(key);
List<String> params = this.map.get(key);
if (params == null) {
params = new ArrayList<>();
map.put(key, params);
this.map.put(key, params);
}
params.add(value);
}
public List<String> getList(String key) throws ParameterNotFoundException {
List<String> params = map.get(key);
List<String> params = this.map.get(key);
if (params == null)
throw ParameterNotFoundException.forParameterName(key);
@ -88,7 +88,7 @@ public final class Parameters {
}
public List<String> getList(String key, List<String> def) {
List<String> params = map.get(key);
List<String> params = this.map.get(key);
if (params == null || params.isEmpty())
return def;
@ -97,7 +97,7 @@ public final class Parameters {
}
public String getString(String key) throws ParameterNotFoundException {
List<String> list = getList(key);
List<String> list = this.getList(key);
if (list.isEmpty())
throw ParameterNotFoundException.forParameterName(key);
@ -106,7 +106,7 @@ public final class Parameters {
}
public String getString(String key, String def) {
List<String> params = map.get(key);
List<String> params = this.map.get(key);
if (params == null || params.isEmpty())
return def;