diff options
author | TheKodeToad <TheKodeToad@proton.me> | 2022-11-08 17:51:18 +0000 |
---|---|---|
committer | TheKodeToad <TheKodeToad@proton.me> | 2022-11-08 17:51:18 +0000 |
commit | 32c2ad2bbd087b83fe5e1cfe03926410ec95bcca (patch) | |
tree | 7e532089643eaab82b84a28ae974e23535ec30fa /libraries/launcher/net/minecraft/Launcher.java | |
parent | f2ca9a6b319ad0ade04837f6830e682bc86c01a2 (diff) | |
download | PrismLauncher-32c2ad2bbd087b83fe5e1cfe03926410ec95bcca.tar.gz PrismLauncher-32c2ad2bbd087b83fe5e1cfe03926410ec95bcca.tar.bz2 PrismLauncher-32c2ad2bbd087b83fe5e1cfe03926410ec95bcca.zip |
A lot more cleanup
Signed-off-by: TheKodeToad <TheKodeToad@proton.me>
Diffstat (limited to 'libraries/launcher/net/minecraft/Launcher.java')
-rw-r--r-- | libraries/launcher/net/minecraft/Launcher.java | 87 |
1 files changed, 46 insertions, 41 deletions
diff --git a/libraries/launcher/net/minecraft/Launcher.java b/libraries/launcher/net/minecraft/Launcher.java index b895d5b7..a721495a 100644 --- a/libraries/launcher/net/minecraft/Launcher.java +++ b/libraries/launcher/net/minecraft/Launcher.java @@ -1,7 +1,6 @@ // SPDX-License-Identifier: GPL-3.0-only /* - * Prism Launcher - * + * Prism Launcher - Minecraft Launcher * Copyright (C) 2022 icelimetea <fr3shtea@outlook.com> * Copyright (C) 2022 TheKodeToad <TheKodeToad@proton.me> * Copyright (C) 2022 solonovamax <solonovamax@12oclockpoint.com> @@ -62,8 +61,10 @@ import java.awt.Dimension; import java.awt.Graphics; import java.net.MalformedURLException; import java.net.URL; +import java.util.HashMap; import java.util.Map; -import java.util.TreeMap; + +import org.prismlauncher.utils.logging.Log; /** * WARNING: This class is reflectively accessed by legacy Forge versions. @@ -75,7 +76,7 @@ public final class Launcher extends Applet implements AppletStub { private static final long serialVersionUID = 1L; - private final Map<String, String> params = new TreeMap<>(); + private final Map<String, String> params = new HashMap<>(); private Applet wrappedApplet; private final URL documentBase; @@ -88,75 +89,75 @@ public final class Launcher extends Applet implements AppletStub { public Launcher(Applet applet, URL documentBase) { setLayout(new BorderLayout()); - this.add(applet, "Center"); + add(applet, "Center"); wrappedApplet = applet; try { - if (documentBase != null) { - this.documentBase = documentBase; - } else if (applet.getClass().getPackage().getName().startsWith("com.mojang.")) { - // Special case only for Classic versions - - // TODO: 2022-10-27 Can this be changed to https - this.documentBase = new URL("http", "www.minecraft.net", 80, "/game/"); - } else { - // TODO: 2022-10-27 Can this be changed to https? - this.documentBase = new URL("http://www.minecraft.net/game/"); + if (documentBase == null) { + if (applet.getClass().getPackage().getName().startsWith("com.mojang.")) { + // Special case only for Classic versions + documentBase = new URL("http", "www.minecraft.net", 80, "/game/"); + } else { + documentBase = new URL("http://www.minecraft.net/game/"); + } } } catch (MalformedURLException e) { - throw new RuntimeException(e); + // handle gracefully - it won't happen, but Java requires that it is caught + Log.error("Failed to parse document base URL", e); } + + this.documentBase = documentBase; } public void replace(Applet applet) { wrappedApplet = applet; applet.setStub(this); - applet.setSize(this.getWidth(), this.getHeight()); + applet.setSize(getWidth(), getHeight()); setLayout(new BorderLayout()); - this.add(applet, "Center"); + add(applet, "Center"); applet.init(); - this.active = true; + active = true; applet.start(); - this.validate(); + validate(); } @Override public boolean isActive() { - return this.active; + return active; } @Override public URL getDocumentBase() { - return this.documentBase; + return documentBase; } @Override public URL getCodeBase() { try { - // TODO: 2022-10-27 Can this be changed to https? return new URL("http://www.minecraft.net/game/"); } catch (MalformedURLException e) { - throw new RuntimeException(e); + Log.error("Failed to parse codebase URL", e); + return null; } } @Override - public String getParameter(String name) { - String param = this.params.get(name); + public String getParameter(String key) { + String param = params.get(key); if (param != null) return param; try { - return super.getParameter(name); - } catch (Exception ignored) { + return super.getParameter(key); + } catch (Throwable ignored) { } return null; @@ -164,49 +165,49 @@ public final class Launcher extends Applet implements AppletStub { @Override public void resize(int width, int height) { - this.wrappedApplet.resize(width, height); + wrappedApplet.resize(width, height); } @Override public void resize(Dimension size) { - this.wrappedApplet.resize(size); + wrappedApplet.resize(size); } @Override public void init() { - if (this.wrappedApplet != null) - this.wrappedApplet.init(); + if (wrappedApplet != null) + wrappedApplet.init(); } @Override public void start() { - this.wrappedApplet.start(); + wrappedApplet.start(); - this.active = true; + active = true; } @Override public void stop() { - this.wrappedApplet.stop(); + wrappedApplet.stop(); - this.active = false; + active = false; } @Override public void destroy() { - this.wrappedApplet.destroy(); + wrappedApplet.destroy(); } @Override public void appletResize(int width, int height) { - this.wrappedApplet.resize(width, height); + wrappedApplet.resize(width, height); } @Override public void setVisible(boolean visible) { super.setVisible(visible); - this.wrappedApplet.setVisible(visible); + wrappedApplet.setVisible(visible); } @Override @@ -217,8 +218,12 @@ public final class Launcher extends Applet implements AppletStub { public void update(Graphics graphics) { } - public void setParameter(String name, String value) { - this.params.put(name, value); + public void setParameter(String key, String value) { + params.put(key, value); + } + + public void setParameter(String key, boolean value) { + setParameter(key, value ? "true" : "false"); } } |