From a7b1700d4232cc055c50286a57d627db23d6b4cd Mon Sep 17 00:00:00 2001 From: TheKodeToad Date: Sat, 29 Oct 2022 15:20:27 +0100 Subject: [PATCH] Better variable naming Signed-off-by: TheKodeToad --- .../launcher/net/minecraft/Launcher.java | 9 ++- .../org/prismlauncher/applet/LegacyFrame.java | 55 +++++++++---------- .../org/prismlauncher/launcher/Launcher.java | 1 + .../launcher/impl/LegacyLauncher.java | 4 +- 4 files changed, 35 insertions(+), 34 deletions(-) diff --git a/libraries/launcher/net/minecraft/Launcher.java b/libraries/launcher/net/minecraft/Launcher.java index 2f8a51c9..aef09ca9 100644 --- a/libraries/launcher/net/minecraft/Launcher.java +++ b/libraries/launcher/net/minecraft/Launcher.java @@ -84,7 +84,6 @@ public final class Launcher extends Applet implements AppletStub { } public Launcher(Applet applet, URL documentBase) { - super(); this.setLayout(new BorderLayout()); this.add(applet, "Center"); @@ -167,8 +166,8 @@ public final class Launcher extends Applet implements AppletStub { } @Override - public void resize(Dimension d) { - wrappedApplet.resize(d); + public void resize(Dimension size) { + wrappedApplet.resize(size); } @Override @@ -209,11 +208,11 @@ public final class Launcher extends Applet implements AppletStub { } @Override - public void paint(Graphics paramGraphics) { + public void paint(Graphics graphics) { } @Override - public void update(Graphics paramGraphics) { + public void update(Graphics graphics) { } public void setParameter(String name, String value) { diff --git a/libraries/launcher/org/prismlauncher/applet/LegacyFrame.java b/libraries/launcher/org/prismlauncher/applet/LegacyFrame.java index 20ec2503..58125160 100644 --- a/libraries/launcher/org/prismlauncher/applet/LegacyFrame.java +++ b/libraries/launcher/org/prismlauncher/applet/LegacyFrame.java @@ -74,19 +74,18 @@ import java.util.List; import java.util.logging.Level; import java.util.logging.Logger; -@SuppressWarnings("removal") public final class LegacyFrame extends Frame { private static final Logger LOGGER = Logger.getLogger("LegacyFrame"); - private final Launcher appletWrap; + private final Launcher launcher; - public LegacyFrame(String title, Applet mcApplet) { + public LegacyFrame(String title, Applet applet) { super(title); - appletWrap = new Launcher(mcApplet); + launcher = new Launcher(applet); - mcApplet.setStub(appletWrap); + applet.setStub(launcher); try { setIconImage(ImageIO.read(new File("icon.png"))); @@ -100,8 +99,8 @@ public final class LegacyFrame extends Frame { public void start ( String user, String session, - int winSizeW, - int winSizeH, + int width, + int height, boolean maximize, String serverAddress, String serverPort, @@ -130,9 +129,9 @@ public final class LegacyFrame extends Frame { LOGGER.warning("Mpticket file is corrupted!"); } else { // Assumes parameters are valid and in the correct order - appletWrap.setParameter("server", lines.get(0)); - appletWrap.setParameter("port", lines.get(1)); - appletWrap.setParameter("mppass", lines.get(2)); + launcher.setParameter("server", lines.get(0)); + launcher.setParameter("port", lines.get(1)); + launcher.setParameter("mppass", lines.get(2)); } } catch (IOException e) { LOGGER.log(Level.WARNING, "Unable to read mpticket file!", e); @@ -140,20 +139,20 @@ public final class LegacyFrame extends Frame { } if (serverAddress != null) { - appletWrap.setParameter("server", serverAddress); - appletWrap.setParameter("port", serverPort); + launcher.setParameter("server", serverAddress); + launcher.setParameter("port", serverPort); } - appletWrap.setParameter("username", user); - appletWrap.setParameter("sessionid", session); - appletWrap.setParameter("stand-alone", "true"); // Show the quit button. TODO: why won't this work? - appletWrap.setParameter("haspaid", "true"); // Some old versions need this for world saves to work. - appletWrap.setParameter("demo", isDemo ? "true" : "false"); - appletWrap.setParameter("fullscreen", "false"); + 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"); - add(appletWrap); + add(launcher); - appletWrap.setPreferredSize(new Dimension(winSizeW, winSizeH)); + launcher.setPreferredSize(new Dimension(width, height)); pack(); @@ -165,8 +164,8 @@ public final class LegacyFrame extends Frame { validate(); - appletWrap.init(); - appletWrap.start(); + launcher.init(); + launcher.start(); setVisible(true); } @@ -174,14 +173,14 @@ public final class LegacyFrame extends Frame { private final class ForceExitHandler extends WindowAdapter { @Override - public void windowClosing(WindowEvent e) { + public void windowClosing(WindowEvent event) { new Thread(new Runnable() { @Override public void run() { try { Thread.sleep(30000L); - } catch (InterruptedException localInterruptedException) { - localInterruptedException.printStackTrace(); + } catch (InterruptedException e) { + e.printStackTrace(); } LOGGER.info("Forcing exit!"); @@ -190,9 +189,9 @@ public final class LegacyFrame extends Frame { } }).start(); - if (appletWrap != null) { - appletWrap.stop(); - appletWrap.destroy(); + if (launcher != null) { + launcher.stop(); + launcher.destroy(); } // old minecraft versions can hang without this >_< diff --git a/libraries/launcher/org/prismlauncher/launcher/Launcher.java b/libraries/launcher/org/prismlauncher/launcher/Launcher.java index a41e4af6..7bf9ba0d 100644 --- a/libraries/launcher/org/prismlauncher/launcher/Launcher.java +++ b/libraries/launcher/org/prismlauncher/launcher/Launcher.java @@ -53,6 +53,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + package org.prismlauncher.launcher; public interface Launcher { diff --git a/libraries/launcher/org/prismlauncher/launcher/impl/LegacyLauncher.java b/libraries/launcher/org/prismlauncher/launcher/impl/LegacyLauncher.java index fb1540bf..ed12cdf6 100644 --- a/libraries/launcher/org/prismlauncher/launcher/impl/LegacyLauncher.java +++ b/libraries/launcher/org/prismlauncher/launcher/impl/LegacyLauncher.java @@ -70,7 +70,9 @@ import java.util.List; import java.util.logging.Level; import java.util.logging.Logger; -@SuppressWarnings("removal") +/** + * Used to launch old versions that support applets. + */ public final class LegacyLauncher extends AbstractLauncher { private static final Logger LOGGER = Logger.getLogger("LegacyLauncher");