Fixed wrong action in mod management.
This commit is contained in:
@@ -50,7 +50,7 @@ public final class Launcher {
|
||||
Thread.currentThread().setName("launcher");
|
||||
println("*** " + Main.makeTitle() + " ***");
|
||||
|
||||
LogWindow.instance.setTerminateGame(Utils::shutdownForcely);
|
||||
LogWindow.instance.setTerminateGame(() -> Utils.shutdownForcely(1));
|
||||
|
||||
boolean showInfo = false;
|
||||
String classPath = "";
|
||||
@@ -75,6 +75,7 @@ public final class Launcher {
|
||||
if (!logFile.exists()) logFile.createNewFile();
|
||||
FileOutputStream tc = new FileOutputStream(logFile);
|
||||
DoubleOutputStream out = new DoubleOutputStream(tc, System.out);
|
||||
Launcher l = new Launcher();
|
||||
System.setOut(new LauncherPrintStream(out));
|
||||
DoubleOutputStream err = new DoubleOutputStream(tc, System.err);
|
||||
System.setErr(new LauncherPrintStream(err));
|
||||
@@ -132,5 +133,6 @@ public final class Launcher {
|
||||
}
|
||||
|
||||
println("*** Game Exited ***");
|
||||
System.exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -193,7 +193,12 @@ public final class Main implements Runnable {
|
||||
});
|
||||
}
|
||||
|
||||
try {
|
||||
MainFrame.showMainFrame(Settings.isFirstLoad());
|
||||
} catch (Throwable t) {
|
||||
new CrashReporter(false).uncaughtException(Thread.currentThread(), t);
|
||||
System.exit(1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -68,9 +68,9 @@ public class OptiFineInstaller extends Task implements PreviousResultRegistrar<F
|
||||
if (new ZipFile(installer).getEntry("optifine/OptiFineTweaker.class") != null) {
|
||||
if (!mv.mainClass.startsWith("net.minecraft.launchwrapper.")) {
|
||||
mv.mainClass = "net.minecraft.launchwrapper.Launch";
|
||||
mv.minecraftArguments += " --tweakClass optifine.OptiFineTweaker";
|
||||
mv.libraries.add(1, new MinecraftLibrary("net.minecraft:launchwrapper:1.7"));
|
||||
}
|
||||
mv.minecraftArguments += " --tweakClass optifine.OptiFineTweaker";
|
||||
}
|
||||
File loc = new File(profile.getCanonicalGameDir(), "versions/" + mv.id);
|
||||
loc.mkdirs();
|
||||
@@ -89,6 +89,7 @@ public class OptiFineInstaller extends Task implements PreviousResultRegistrar<F
|
||||
}
|
||||
|
||||
ArrayList<PreviousResult<File>> pre = new ArrayList();
|
||||
|
||||
@Override
|
||||
public Task registerPreviousResult(PreviousResult pr) {
|
||||
pre.add(pr);
|
||||
|
||||
@@ -28,6 +28,7 @@ import java.awt.dnd.DropTargetListener;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
import java.awt.event.ItemEvent;
|
||||
import java.awt.event.KeyEvent;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
@@ -1439,6 +1440,7 @@ btnRefreshLiteLoader.addActionListener(new java.awt.event.ActionListener() {
|
||||
}//GEN-LAST:event_btnRemoveModActionPerformed
|
||||
|
||||
private void lstExternalModsKeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_lstExternalModsKeyPressed
|
||||
if(evt.getKeyCode() == KeyEvent.VK_DELETE)
|
||||
btnRemoveModActionPerformed(null);
|
||||
}//GEN-LAST:event_lstExternalModsKeyPressed
|
||||
|
||||
|
||||
@@ -41,7 +41,8 @@ public class LauncherPrintStream extends PrintStream {
|
||||
a1.accept(paramString);
|
||||
}
|
||||
|
||||
public final void addPrintListener(Consumer<String> paraml) {
|
||||
public final LauncherPrintStream addPrintListener(Consumer<String> paraml) {
|
||||
this.printListeners.add(paraml);
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -168,12 +168,12 @@ public final class Utils {
|
||||
/**
|
||||
* In order to fight against the permission manager.
|
||||
*/
|
||||
public static void shutdownForcely() {
|
||||
public static void shutdownForcely(int status) {
|
||||
try {
|
||||
Class z = Class.forName("java.lang.Shutdown");
|
||||
Method exit = z.getDeclaredMethod("exit", int.class);
|
||||
exit.setAccessible(true);
|
||||
exit.invoke(z, 0);
|
||||
exit.invoke(z, status);
|
||||
} catch (ClassNotFoundException | NoSuchMethodException | SecurityException | IllegalAccessException | IllegalArgumentException | InvocationTargetException e) {
|
||||
MessageBox.Show(C.i18n("launcher.exit_failed"));
|
||||
e.printStackTrace();
|
||||
|
||||
@@ -23,7 +23,7 @@ package org.jackhuang.hellominecraft.utils.functions;
|
||||
public class FalseFunction implements NonFunction<Boolean> {
|
||||
|
||||
@Override
|
||||
public Boolean onDone() {
|
||||
public Boolean apply() {
|
||||
return Boolean.FALSE;
|
||||
}
|
||||
|
||||
|
||||
@@ -22,5 +22,5 @@ package org.jackhuang.hellominecraft.utils.functions;
|
||||
*/
|
||||
public interface NonFunction<T> {
|
||||
|
||||
T onDone();
|
||||
T apply();
|
||||
}
|
||||
|
||||
@@ -27,7 +27,7 @@ public class TrueFunction implements NonFunction<Boolean> {
|
||||
private TrueFunction(){}
|
||||
|
||||
@Override
|
||||
public Boolean onDone() {
|
||||
public Boolean apply() {
|
||||
return Boolean.TRUE;
|
||||
}
|
||||
|
||||
|
||||
@@ -40,6 +40,9 @@ public class JavaProcessMonitor {
|
||||
|
||||
public void start() {
|
||||
Event<JavaProcess> event = (sender2, t) -> {
|
||||
if(t.getExitCode() != 0) {
|
||||
MessageBox.Show(C.i18n("launch.exited_abnormally"));
|
||||
}
|
||||
processThreadStopped((ProcessThread) sender2, false);
|
||||
return true;
|
||||
};
|
||||
|
||||
@@ -16,7 +16,6 @@
|
||||
*/
|
||||
package org.jackhuang.hellominecraft.utils.system;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.InputStream;
|
||||
import java.io.InputStreamReader;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
@@ -47,23 +46,25 @@ public class ProcessThread extends Thread {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
InputStream in = null;
|
||||
BufferedReader br = null;
|
||||
if (enableReading)
|
||||
in = readError ? p.getRawProcess().getErrorStream() : p.getRawProcess().getInputStream();
|
||||
try {
|
||||
if (enableReading)
|
||||
InputStreamReader br;
|
||||
if (enableReading) {
|
||||
InputStream in = readError ? p.getRawProcess().getErrorStream() : p.getRawProcess().getInputStream();
|
||||
try {
|
||||
br = new BufferedReader(new InputStreamReader(in, System.getProperty("sun.jnu.encoding", "UTF-8")));
|
||||
br = new InputStreamReader(in, System.getProperty("sun.jnu.encoding", "UTF-8"));
|
||||
} catch (UnsupportedEncodingException ex) {
|
||||
HMCLog.warn("Unsupported encoding: " + System.getProperty("sun.jnu.encoding", "UTF-8"), ex);
|
||||
br = new BufferedReader(new InputStreamReader(in));
|
||||
br = new InputStreamReader(in);
|
||||
}
|
||||
}
|
||||
else br = null;
|
||||
|
||||
String line;
|
||||
int ch;
|
||||
String line = "";
|
||||
while (p.isRunning())
|
||||
if (enableReading)
|
||||
while ((line = br.readLine()) != null) {
|
||||
if (br != null)
|
||||
while ((ch = br.read()) != -1)
|
||||
if (ch == '\n') {
|
||||
printlnEvent.execute(line);
|
||||
if (readError) {
|
||||
System.err.println(line);
|
||||
@@ -72,14 +73,17 @@ public class ProcessThread extends Thread {
|
||||
System.out.println(line);
|
||||
p.getStdOutLines().add(line);
|
||||
}
|
||||
}
|
||||
line = "";
|
||||
} else
|
||||
line += (char) ch;
|
||||
else
|
||||
try {
|
||||
Thread.sleep(1);
|
||||
} catch (Exception e) {
|
||||
}
|
||||
if (enableReading)
|
||||
while ((line = br.readLine()) != null) {
|
||||
if (br != null)
|
||||
while ((ch = br.read()) != -1)
|
||||
if (ch == '\n') {
|
||||
printlnEvent.execute(line);
|
||||
if (readError) {
|
||||
System.err.println(line);
|
||||
@@ -88,13 +92,12 @@ public class ProcessThread extends Thread {
|
||||
System.out.println(line);
|
||||
p.getStdOutLines().add(line);
|
||||
}
|
||||
}
|
||||
line = "";
|
||||
} else
|
||||
line += (char) ch;
|
||||
stopEvent.execute(p);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
private void stopped() {
|
||||
}
|
||||
}
|
||||
|
||||
@@ -204,7 +204,8 @@ public class LogWindow extends javax.swing.JFrame {
|
||||
}//GEN-LAST:event_btnClearActionPerformed
|
||||
|
||||
private void formWindowClosed(java.awt.event.WindowEvent evt) {//GEN-FIRST:event_formWindowClosed
|
||||
if (listener != null && listener.onDone()) Utils.shutdownForcely();
|
||||
if (listener != null && listener.apply() && terminateGameListener != null)
|
||||
terminateGameListener.run();
|
||||
}//GEN-LAST:event_formWindowClosed
|
||||
|
||||
private void btnCopyActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnCopyActionPerformed
|
||||
|
||||
@@ -24,6 +24,7 @@ launch.circular_dependency_versions=\u53d1\u73b0\u6e38\u620f\u7248\u672c\u5faa\u
|
||||
launch.not_finished_downloading_libraries=\u672a\u5b8c\u6210\u6e38\u620f\u4f9d\u8d56\u5e93\u7684\u4e0b\u8f7d\uff0c\u8fd8\u8981\u7ee7\u7eed\u542f\u52a8\u6e38\u620f\u5417\uff1f
|
||||
launch.not_finished_decompressing_natives=\u672a\u80fd\u89e3\u538b\u6e38\u620f\u672c\u5730\u5e93\uff0c\u8fd8\u8981\u7ee7\u7eed\u542f\u52a8\u6e38\u620f\u5417\uff1f
|
||||
launch.wrong_javadir=\u9519\u8bef\u7684Java\u8def\u5f84\uff0c\u5c06\u81ea\u52a8\u91cd\u7f6e\u4e3a\u9ed8\u8ba4Java\u8def\u5f84\u3002
|
||||
launch.exited_abnormally=\u6e38\u620f\u975e\u6b63\u5e38\u9000\u51fa\uff0c\u8bf7\u67e5\u770b\u65e5\u5fd7\u6587\u4ef6\uff0c\u6216\u8054\u7cfb\u4ed6\u4eba\u5bfb\u6c42\u5e2e\u52a9\u3002
|
||||
|
||||
install.no_version=\u672a\u627e\u5230\u8981\u5b89\u88c5\u7684\u5bf9\u5e94MC\u7248\u672c
|
||||
install.no_version_if_intall=\u672a\u627e\u5230\u8981\u5b89\u88c5\u7684\u5bf9\u5e94MC\u7248\u672c\uff0c\u662f\u5426\u81ea\u52a8\u5b89\u88c5\u9700\u8981\u7684MC\u7248\u672c\uff1f
|
||||
|
||||
@@ -24,6 +24,7 @@ launch.circular_dependency_versions=Found circular dependency versions, please c
|
||||
launch.not_finished_downloading_libraries=Did not finish downloading libraries, continue launching game?
|
||||
launch.not_finished_decompressing_natives=Did not finish decompressing native libraries, continue launching game?
|
||||
launch.wrong_javadir=Wrong Java Dir, will reset to default Java dir.
|
||||
launch.exited_abnormally=Game exited abnormally, please visit the log, or ask someone for help.
|
||||
|
||||
install.no_version=The version is not found.
|
||||
install.no_version_if_intall=The needed version is not found, should install the version automatically?
|
||||
|
||||
@@ -24,6 +24,7 @@ launch.circular_dependency_versions=\u53d1\u73b0\u6e38\u620f\u7248\u672c\u5faa\u
|
||||
launch.not_finished_downloading_libraries=\u672a\u5b8c\u6210\u6e38\u620f\u4f9d\u8d56\u5e93\u7684\u4e0b\u8f7d\uff0c\u8fd8\u8981\u7ee7\u7eed\u542f\u52a8\u6e38\u620f\u5417\uff1f
|
||||
launch.not_finished_decompressing_natives=\u672a\u80fd\u89e3\u538b\u6e38\u620f\u672c\u5730\u5e93\uff0c\u8fd8\u8981\u7ee7\u7eed\u542f\u52a8\u6e38\u620f\u5417\uff1f
|
||||
launch.wrong_javadir=\u9519\u8bef\u7684Java\u8def\u5f84\uff0c\u5c06\u81ea\u52a8\u91cd\u7f6e\u4e3a\u9ed8\u8ba4Java\u8def\u5f84\u3002
|
||||
launch.exited_abnormally=\u6e38\u620f\u975e\u6b63\u5e38\u9000\u51fa\uff0c\u8bf7\u67e5\u770b\u65e5\u5fd7\u6587\u4ef6\uff0c\u6216\u8054\u7cfb\u4ed6\u4eba\u5bfb\u6c42\u5e2e\u52a9\u3002
|
||||
|
||||
install.no_version=\u672a\u627e\u5230\u8981\u5b89\u88c5\u7684\u5bf9\u5e94MC\u7248\u672c
|
||||
install.no_version_if_intall=\u672a\u627e\u5230\u8981\u5b89\u88c5\u7684\u5bf9\u5e94MC\u7248\u672c\uff0c\u662f\u5426\u81ea\u52a8\u5b89\u88c5\u9700\u8981\u7684MC\u7248\u672c\uff1f
|
||||
|
||||
@@ -24,6 +24,7 @@ launch.circular_dependency_versions=\u767c\u73fe\u904a\u6232\u7248\u672c\u5faa\u
|
||||
launch.not_finished_downloading_libraries=\u672a\u5b8c\u6210\u904a\u6232\u4f9d\u8cf4\u5eab\u7684\u4e0b\u8f09\uff0c\u9084\u8981\u7e7c\u7e8c\u555f\u52d5\u904a\u6232\u55ce\uff1f
|
||||
launch.not_finished_decompressing_natives=\u672a\u80fd\u89e3\u58d3\u904a\u6232\u672c\u5730\u5eab\uff0c\u9084\u8981\u7e7c\u7e8c\u555f\u52d5\u904a\u6232\u55ce\uff1f
|
||||
launch.wrong_javadir=\u932f\u8aa4\u7684Java\u8def\u5f91\uff0c\u5c07\u81ea\u52d5\u91cd\u7f6e\u70ba\u9ed8\u8a8dJava\u8def\u5f91\u3002
|
||||
launch.exited_abnormally=\u904a\u6232\u975e\u6b63\u5e38\u9000\u51fa\uff0c\u8acb\u67e5\u770b\u65e5\u8a8c\u6587\u4ef6\uff0c\u6216\u806f\u7e6b\u4ed6\u4eba\u5c0b\u6c42\u5e6b\u52a9\u3002
|
||||
|
||||
install.no_version=\u672a\u627e\u5230\u8981\u5b89\u88dd\u7684\u5c0d\u61c9MC\u7248\u672c
|
||||
install.no_version_if_intall=\u672a\u627e\u5230\u8981\u5b89\u88dd\u7684\u5c0d\u61c9MC\u7248\u672c\uff0c\u662f\u5426\u81ea\u52a8\u5b89\u88c5\u9700\u8981\u7684MC\u7248\u672c\uff1f
|
||||
|
||||
Reference in New Issue
Block a user