Refactor some parts of NewLaunch (part 2)
This commit is contained in:
@ -16,29 +16,28 @@
|
||||
|
||||
package net.minecraft;
|
||||
|
||||
import java.util.TreeMap;
|
||||
import java.util.Map;
|
||||
import java.net.URL;
|
||||
import java.awt.Dimension;
|
||||
import java.awt.BorderLayout;
|
||||
import java.awt.Graphics;
|
||||
import java.applet.Applet;
|
||||
import java.applet.AppletStub;
|
||||
import java.awt.*;
|
||||
import java.net.MalformedURLException;
|
||||
import java.net.URL;
|
||||
import java.util.Map;
|
||||
import java.util.TreeMap;
|
||||
|
||||
public class Launcher extends Applet implements AppletStub {
|
||||
|
||||
private final Map<String, String> params = new TreeMap<>();
|
||||
|
||||
private boolean active = false;
|
||||
|
||||
public class Launcher extends Applet implements AppletStub
|
||||
{
|
||||
private Applet wrappedApplet;
|
||||
private URL documentBase;
|
||||
private boolean active = false;
|
||||
private final Map<String, String> params;
|
||||
|
||||
public Launcher(Applet applet, URL documentBase)
|
||||
{
|
||||
params = new TreeMap<String, String>();
|
||||
|
||||
public Launcher(Applet applet, URL documentBase) {
|
||||
this.setLayout(new BorderLayout());
|
||||
|
||||
this.add(applet, "Center");
|
||||
|
||||
this.wrappedApplet = applet;
|
||||
this.documentBase = documentBase;
|
||||
}
|
||||
@ -48,8 +47,7 @@ public class Launcher extends Applet implements AppletStub
|
||||
params.put(name, value);
|
||||
}
|
||||
|
||||
public void replace(Applet applet)
|
||||
{
|
||||
public void replace(Applet applet) {
|
||||
this.wrappedApplet = applet;
|
||||
|
||||
applet.setStub(this);
|
||||
@ -65,67 +63,60 @@ public class Launcher extends Applet implements AppletStub
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getParameter(String name)
|
||||
{
|
||||
public String getParameter(String name) {
|
||||
String param = params.get(name);
|
||||
|
||||
if (param != null)
|
||||
return param;
|
||||
try
|
||||
{
|
||||
|
||||
try {
|
||||
return super.getParameter(name);
|
||||
} catch (Exception ignore){}
|
||||
} catch (Exception ignore) {}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isActive()
|
||||
{
|
||||
public boolean isActive() {
|
||||
return active;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void appletResize(int width, int height)
|
||||
{
|
||||
public void appletResize(int width, int height) {
|
||||
wrappedApplet.resize(width, height);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void resize(int width, int height)
|
||||
{
|
||||
public void resize(int width, int height) {
|
||||
wrappedApplet.resize(width, height);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void resize(Dimension d)
|
||||
{
|
||||
public void resize(Dimension d) {
|
||||
wrappedApplet.resize(d);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init()
|
||||
{
|
||||
public void init() {
|
||||
if (wrappedApplet != null)
|
||||
{
|
||||
wrappedApplet.init();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void start()
|
||||
{
|
||||
public void start() {
|
||||
wrappedApplet.start();
|
||||
|
||||
active = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void stop()
|
||||
{
|
||||
public void stop() {
|
||||
wrappedApplet.stop();
|
||||
|
||||
active = false;
|
||||
}
|
||||
|
||||
public void destroy()
|
||||
{
|
||||
public void destroy() {
|
||||
wrappedApplet.destroy();
|
||||
}
|
||||
|
||||
@ -136,34 +127,35 @@ public class Launcher extends Applet implements AppletStub
|
||||
} catch (MalformedURLException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public URL getDocumentBase()
|
||||
{
|
||||
public URL getDocumentBase() {
|
||||
try {
|
||||
// Special case only for Classic versions
|
||||
if (wrappedApplet.getClass().getCanonicalName().startsWith("com.mojang")) {
|
||||
return new URL("http", "www.minecraft.net", 80, "/game/", null);
|
||||
}
|
||||
|
||||
return new URL("http://www.minecraft.net/game/");
|
||||
} catch (MalformedURLException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setVisible(boolean b)
|
||||
{
|
||||
public void setVisible(boolean b) {
|
||||
super.setVisible(b);
|
||||
|
||||
wrappedApplet.setVisible(b);
|
||||
}
|
||||
public void update(Graphics paramGraphics)
|
||||
{
|
||||
}
|
||||
public void paint(Graphics paramGraphics)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
public void update(Graphics paramGraphics) {}
|
||||
|
||||
public void paint(Graphics paramGraphics) {}
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user