Skip to content

Commit

Permalink
1.09_13-pre1, public macos fixes testing
Browse files Browse the repository at this point in the history
  • Loading branch information
Moresteck committed Apr 9, 2021
1 parent ebbbad7 commit 8303823
Show file tree
Hide file tree
Showing 12 changed files with 145 additions and 136 deletions.
15 changes: 4 additions & 11 deletions src/main/java/org/betacraft/ClassicWrapper.java
Original file line number Diff line number Diff line change
Expand Up @@ -34,25 +34,18 @@ public ClassicWrapper(String user, String ver_prefix, String version, String ses
public void loadMainClass(URL[] url) {
try {
URL[] old = url.clone();
URL[] neww = new URL[old.length/* + ogaddons.size()*/];
URL[] neww = new URL[old.length];

int i;
for (i = 0; i < old.length; i++) {
neww[i] = old[i];
}
/*if (i < neww.length) {
for (String c : ogaddons) {
neww[i] = new File(c).toURI().toURL();
i++;
}
}*/

classLoader = new BCClassLoader(neww);
try {
for (Class<Addon> c : ogaddons) {
/*String[] split = c.split("\\.");
String split2[] = split[split.length - 2].split(File.separator);
Class<?> addon = classLoader.loadClass(split2[split2.length - 1]);*/
this.loadAddon((Addon) c.newInstance());
System.out.println("- " + c);
System.err.println("- " + c);
}
} catch (Exception ex) {
ex.printStackTrace();
Expand Down
13 changes: 2 additions & 11 deletions src/main/java/org/betacraft/FkWrapper.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,25 +28,16 @@ public FkWrapper(String user, String ver_prefix, String version, String sessioni
public void loadMainClass(URL[] url) {
try {
URL[] old = url.clone();
URL[] neww = new URL[old.length/* + ogaddons.size()*/];
URL[] neww = new URL[old.length];
int i;
for (i = 0; i < old.length; i++) {
neww[i] = old[i];
}
/*if (i < neww.length) {
for (String c : ogaddons) {
neww[i] = new File(c).toURI().toURL();
i++;
}
}*/
classLoader = new BCClassLoader(neww);
try {
for (Class<Addon> c : ogaddons) {
/*String[] split = c.split("\\.");
String split2[] = split[split.length - 2].split(File.separator);
Class<?> addon = classLoader.loadClass(split2[split2.length - 1]);*/
this.loadAddon((Addon) c.newInstance());
System.out.println("- " + c);
System.err.println("- " + c);
}
} catch (Exception ex) {
ex.printStackTrace();
Expand Down
21 changes: 5 additions & 16 deletions src/main/java/org/betacraft/PreClassicWrapper.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,17 +24,13 @@ public void loadMainClass(URL[] url) {
try {
classLoader = null;
URL[] old = url.clone();
URL[] neww = new URL[old.length/* + ogaddons.size()*/];
URL[] neww = new URL[old.length];

int i;
for (i = 0; i < old.length; i++) {
neww[i] = old[i];
}
/*if (i < neww.length) {
for (String c : ogaddons) {
neww[i] = new File(c).toURI().toURL();
i++;
}
}*/

classLoader = new BCClassLoader(neww);
} catch (Exception ex) {
ex.printStackTrace();
Expand All @@ -55,24 +51,17 @@ public void loadMainClass(URL[] url) {
}
try {
for (Class<Addon> c : ogaddons) {
/*String[] split = c.split("\\.");
String split2[] = split[split.length - 2].split(File.separator);
Class<?> addon = classLoader.loadClass(split2[split2.length - 1]);*/
this.loadAddon((Addon) c.newInstance());
System.out.println("- " + c);
System.err.println("- " + c);
}
} catch (Exception ex) {
ex.printStackTrace();
Logger.printException(ex);
}
try {
//PreClassicHooker r = new PreClassicHooker(this.width, this.height, this.ver_prefix, this.icon, appletClass);
//Class e = classLoader.loadClass("org.betacraft.PreClassicHooker");
//Constructor constr = e.getConstructor(int.class, int.class, String.class, Image.class, Class.class);
//PreClassicHooker run = (PreClassicHooker) constr.newInstance(this.width, this.height, this.ver_prefix, this.icon, appletClass);
mainClassInstance = mainClass.newInstance();
if (!this.addonsPreAppletInit(this.addons)) return;
System.out.println(mainClassInstance.getClass().getName());
System.err.println(mainClassInstance.getClass().getName());
Thread t = new Thread() {
public void run() {
((Runnable)mainClassInstance).run();
Expand Down
13 changes: 3 additions & 10 deletions src/main/java/org/betacraft/PreClassicWrapper2.java
Original file line number Diff line number Diff line change
Expand Up @@ -36,17 +36,13 @@ public PreClassicWrapper2(String user, String ver_prefix, String version, String
public void loadMainClass(URL[] url) {
try {
URL[] old = url.clone();
URL[] neww = new URL[old.length/* + ogaddons.size()*/ + 1];
URL[] neww = new URL[old.length + 1];

int i;
for (i = 0; i < old.length; i++) {
neww[i] = old[i];
}
/*if (i < neww.length - 1) {
for (String c : ogaddons) {
neww[i] = new File(c).toURI().toURL();
i++;
}
}*/

neww[neww.length-1] = new File(BC.get() + "launcher/", "PreClassic.jar").toURI().toURL();
classLoader = new BCClassLoader(neww);
try {
Expand All @@ -64,9 +60,6 @@ public void loadMainClass(URL[] url) {
}
try {
for (Class<Addon> c : ogaddons) {
/*String[] split = c.split("\\.");
String split2[] = split[split.length - 2].split(File.separator);
Class<?> addon = classLoader.loadClass(split2[split2.length - 1]);*/
this.loadAddon((Addon) c.newInstance());
System.out.println("- " + c);
}
Expand Down
51 changes: 29 additions & 22 deletions src/main/java/org/betacraft/Wrapper.java
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,9 @@ public class Wrapper extends Applet implements AppletStub {
public ArrayList<Addon> addons = new ArrayList<>();
public ArrayList<Class<Addon>> ogaddons = new ArrayList<>();

/** Tells whether lwjgl dependencies have been already loaded or not */
public boolean libraries_loaded = false;

/**
* Initializes the Wrapper class & enables the game
*
Expand Down Expand Up @@ -113,7 +116,7 @@ public Wrapper(String user, String ver_prefix, String version, String sessionid,
this.session = sessionid;
this.launchType = launchMethod;
if (this.launchType.equalsIgnoreCase("")) {
System.out.println("LAUNCH METHOD ISN'T SPECIFIED!!! CANNOT PROCEED! CLOSING!");
System.err.println("LAUNCH METHOD ISN'T SPECIFIED!!! CANNOT PROCEED! CLOSING!");
System.exit(0);
}
this.mainFolder = mainFolder;
Expand All @@ -133,6 +136,10 @@ public Wrapper(String user, String ver_prefix, String version, String sessionid,
this.portCompat = Integer.parseInt(port);
}

try {
this.libraries_loaded = Boolean.parseBoolean(System.getProperty("betacraft.loaded_libraries"));
} catch (Throwable t) {}

if (this.discord) {
String applicationId = "567450523603566617";
DiscordEventHandlers handlers = new DiscordEventHandlers();
Expand Down Expand Up @@ -244,7 +251,7 @@ public void askForServer() {
}
// <ip>
if (!server.equals("")) {
System.out.println("Accepted server parameters: " + IP + ":" + port + this.mppass != null ? " + mppass" : "");
System.err.println("Accepted server parameters: " + IP + ":" + port + this.mppass != null ? " + mppass" : "");
params.put("server", IP);
params.put("port", port);
params.put("mppass", this.mppass);
Expand Down Expand Up @@ -276,25 +283,16 @@ public void loadMainClass(URL[] url) {
try {
classLoader = null;
URL[] old = url.clone();
URL[] neww = new URL[old.length/* + ogaddons.size()*/];
URL[] neww = new URL[old.length];
int i;
for (i = 0; i < old.length; i++) {
neww[i] = old[i];
}
/*if (i < neww.length) {
for (String c : ogaddons) {
neww[i] = new File(c).toURI().toURL();
i++;
}
}*/
classLoader = new BCClassLoader(neww);
try {
for (Class<Addon> c : ogaddons) {
/*String[] split = c.split("\\.");
String split2[] = split[split.length - 2].split(File.separator);
Class<?> addon = Launcher.class.getClassLoader().loadClass(split2[split2.length - 1]);*/
this.loadAddon((Addon) c.newInstance());
System.out.println("- " + c);
System.err.println("- " + c);
}
} catch (Exception ex) {
ex.printStackTrace();
Expand Down Expand Up @@ -362,10 +360,17 @@ public void setGameFolder() {
}
} catch (ClassNotFoundException ex) {
String err = "Error code 6 (MISSING): Couldn't satisfy the wrapper with a valid .jar file. Check your version JAR or launch configuration file.";
System.out.println(err);
System.err.println(err);
JOptionPane.showMessageDialog(gameFrame, err, "Error", JOptionPane.INFORMATION_MESSAGE);
ex.printStackTrace();
} catch (Exception ex) {
System.exit(0);
} catch (NoClassDefFoundError ex) {
String err = "Error code 5 (LIB_MISSING): Some of the required libraries are missing. Select \"Force update\" in instance settings to re-download them.";
System.err.println(err);
JOptionPane.showMessageDialog(gameFrame, err, "Error", JOptionPane.INFORMATION_MESSAGE);
ex.printStackTrace();
System.exit(0);
} catch (Throwable ex) {
ex.printStackTrace();
}
}
Expand All @@ -380,12 +385,14 @@ public boolean accept(File dir, String fileName) {
});

// Glue everything Minecraft needs for running
String[] files = new String[libs.length + 1];
String[] files = new String[1 + (this.libraries_loaded ? 0 : libs.length)];

files[0] = BC.get() + "versions/" + version + ".jar";

for (int i = 0; i < libs.length; i++) {
files[i + 1] = BC.get() + "bin/" + libs[i];
if (!this.libraries_loaded) {
for (int i = 0; i < libs.length; i++) {
files[i + 1] = BC.get() + "bin/" + libs[i];
}
}

String nativesPath = BC.get() + "bin/natives";
Expand All @@ -394,7 +401,7 @@ public boolean accept(File dir, String fileName) {

final URL[] url = new URL[files.length];
for (int i = 0; i < files.length; i++) {
System.out.println(files[i]);
System.err.println(files[i]);
url[i] = new File(files[i]).toURI().toURL();
}

Expand Down Expand Up @@ -453,7 +460,7 @@ public void play() {
// Start Discord RPC
if (discord) discordThread.start();
} catch (Throwable ex) {
System.out.println("A critical error has occurred!");
System.err.println("A critical error has occurred!");
ex.printStackTrace();
}
}
Expand Down Expand Up @@ -599,7 +606,7 @@ public URL getDocumentBase() {
url = new URL("http", "www.minecraft.net", portCompat, "/game/", null);
}
}
System.out.println(url.toString());
System.err.println(url.toString());
return url;
}
catch (Exception e) {
Expand All @@ -621,7 +628,7 @@ public URL getCodeBase() {

@Override
public String getParameter(final String paramName) {
System.out.println("Client asked for a parameter: " + paramName);
System.err.println("Client asked for a parameter: " + paramName);
if (params.containsKey(paramName)) {
return params.get(paramName);
}
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/org/betacraft/launcher/BC.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ public class BC {
public static File SETTINGS;

// TODO better check this before release
public static boolean prerelease = false;
public static boolean prerelease = true;
public static boolean nightly = false;

public static boolean portable = false;
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/org/betacraft/launcher/Instance.java
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ private Instance(String name, String launchArgs, String version, int width, int

public static Instance newInstance(String name) {
// Use default settings
return new Instance(name, "-Xmx512M", "b1.6.6", 854, 480, true, false, false, new ArrayList<String>(), BC.get() + name + "/");
return new Instance(name, "-Xmx512M", "b1.7.3", 854, 480, true, false, false, new ArrayList<String>(), BC.get() + name + "/");
}

public static Instance loadInstance(String name) {
Expand Down
Loading

0 comments on commit 8303823

Please sign in to comment.