Fixed logging conflicting with Log4j and Minecraft.

This commit is contained in:
huanghongxun
2015-11-16 23:26:23 +08:00
parent b7aa99550d
commit 39b6d68006
3 changed files with 8 additions and 8 deletions

View File

@@ -25,7 +25,7 @@ if (!hasProperty('mainClass')) {
ext.mainClass = 'org.jackhuang.hellominecraft.launcher.Main'
}
def buildnumber = System.getenv("BUILD_NUMBER") == null ? ".4" : "."+System.getenv("BUILD_NUMBER")
def buildnumber = System.getenv("BUILD_NUMBER") == null ? ".5" : "."+System.getenv("BUILD_NUMBER")
String mavenGroupId = 'HMCL'
String mavenVersion = '2.3.5' + buildnumber

View File

@@ -24,7 +24,6 @@ import java.net.URLClassLoader;
import java.util.ArrayList;
import javax.swing.SwingUtilities;
import org.jackhuang.hellominecraft.C;
import org.jackhuang.hellominecraft.HMCLog;
import org.jackhuang.hellominecraft.utils.functions.TrueFunction;
import org.jackhuang.hellominecraft.utils.StrUtils;
import org.jackhuang.hellominecraft.views.LogWindow;
@@ -98,8 +97,10 @@ public final class Launcher {
}
Method minecraftMain;
URLClassLoader ucl = new URLClassLoader(urls, URLClassLoader.getSystemClassLoader().getParent());
Thread.currentThread().setContextClassLoader(ucl);
try {
minecraftMain = new URLClassLoader(urls, URLClassLoader.getSystemClassLoader()).loadClass(mainClass).getMethod("main", String[].class);
minecraftMain = ucl.loadClass(mainClass).getMethod("main", String[].class);
} catch (ClassNotFoundException | NoSuchMethodException | SecurityException t) {
MessageBox.Show(C.i18n("crash.main_class_not_found"));
println("Minecraft main class not found.");
@@ -113,15 +114,14 @@ public final class Launcher {
try {
minecraftMain.invoke(null, new Object[]{(String[]) cmdList.toArray(new String[cmdList.size()])});
} catch (Throwable throwable) {
HMCLog.err("Cought exception!");
String trace = StrUtils.getStackTrace(throwable);
final String advice = MinecraftCrashAdvicer.getAdvice(trace);
MessageBox.Show(C.i18n("crash.minecraft") + ": " + advice);
LogWindow.instance.warning(C.i18n("crash.minecraft"));
LogWindow.instance.warning(advice);
LogWindow.instance.warning(trace);
LogWindow.instance.setExit(TrueFunction.instance);
System.err.println(C.i18n("crash.minecraft"));
System.err.println(advice);
System.err.println(trace);
LogWindow.instance.setVisible(true);
flag = 1;

View File

@@ -102,7 +102,7 @@ public final class Main implements Runnable {
}
public static String launcherName = "Hello Minecraft! Launcher";
public static byte firstVer = 2, secondVer = 3, thirdVer = 5, forthVer = 4;
public static byte firstVer = 2, secondVer = 3, thirdVer = 5, forthVer = 5;
public static int minimumLauncherVersion = 16;
/**