Make Launcher class to look more like original
This commit is contained in:
parent
cd49406bfe
commit
dd6d8e0002
@ -24,12 +24,18 @@ import java.net.URL;
|
|||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.TreeMap;
|
import java.util.TreeMap;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* WARNING: This class is reflectively accessed by legacy Forge versions.
|
||||||
|
* Changing field and method declarations without further testing is not recommended.
|
||||||
|
*/
|
||||||
public final class Launcher extends Applet implements AppletStub {
|
public final class Launcher extends Applet implements AppletStub {
|
||||||
|
|
||||||
private final Map<String, String> params = new TreeMap<>();
|
private final Map<String, String> params = new TreeMap<>();
|
||||||
|
|
||||||
private Applet wrappedApplet;
|
private Applet wrappedApplet;
|
||||||
|
|
||||||
|
private URL documentBase;
|
||||||
|
|
||||||
private boolean active = false;
|
private boolean active = false;
|
||||||
|
|
||||||
public Launcher(Applet applet) {
|
public Launcher(Applet applet) {
|
||||||
@ -42,6 +48,20 @@ public final class Launcher extends Applet implements AppletStub {
|
|||||||
this.add(applet, "Center");
|
this.add(applet, "Center");
|
||||||
|
|
||||||
this.wrappedApplet = applet;
|
this.wrappedApplet = applet;
|
||||||
|
|
||||||
|
try {
|
||||||
|
if (documentBase != null) {
|
||||||
|
this.documentBase = documentBase;
|
||||||
|
} else if (applet.getClass().getPackage().getName().startsWith("com.mojang")) {
|
||||||
|
// Special case only for Classic versions
|
||||||
|
|
||||||
|
this.documentBase = new URL("http", "www.minecraft.net", 80, "/game/");
|
||||||
|
} else {
|
||||||
|
this.documentBase = new URL("http://www.minecraft.net/game/");
|
||||||
|
}
|
||||||
|
} catch (MalformedURLException e) {
|
||||||
|
throw new RuntimeException(e);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void replace(Applet applet) {
|
public void replace(Applet applet) {
|
||||||
@ -75,7 +95,7 @@ public final class Launcher extends Applet implements AppletStub {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
return super.getParameter(name);
|
return super.getParameter(name);
|
||||||
} catch (Exception ignore) {}
|
} catch (Exception ignored) {}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@ -129,25 +149,13 @@ public final class Launcher extends Applet implements AppletStub {
|
|||||||
try {
|
try {
|
||||||
return new URL("http://www.minecraft.net/game/");
|
return new URL("http://www.minecraft.net/game/");
|
||||||
} catch (MalformedURLException e) {
|
} catch (MalformedURLException e) {
|
||||||
e.printStackTrace();
|
throw new RuntimeException(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public URL getDocumentBase() {
|
public URL getDocumentBase() {
|
||||||
try {
|
return documentBase;
|
||||||
// Special case only for Classic versions
|
|
||||||
if (wrappedApplet.getClass().getCanonicalName().startsWith("com.mojang"))
|
|
||||||
return new URL("http", "www.minecraft.net", 80, "/game/");
|
|
||||||
|
|
||||||
return new URL("http://www.minecraft.net/game/");
|
|
||||||
} catch (MalformedURLException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
|
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
Loading…
Reference in New Issue
Block a user