Fixed: Cannot cancel modpack installing
This commit is contained in:
@@ -46,6 +46,7 @@ import org.jackhuang.hellominecraft.util.system.ZipEngine;
|
||||
import org.jackhuang.hellominecraft.util.tasks.Task;
|
||||
import org.jackhuang.hellominecraft.util.ui.WebPage;
|
||||
import org.jackhuang.hellominecraft.util.MinecraftVersionRequest;
|
||||
import org.jackhuang.hellominecraft.util.tasks.NoShownTaskException;
|
||||
|
||||
/**
|
||||
* A mod pack(*.zip) includes these things:
|
||||
@@ -111,7 +112,7 @@ public final class ModpackManager {
|
||||
((WebPage) msgs[1]).setPreferredSize(new Dimension(800, 350));
|
||||
int result = JOptionPane.showOptionDialog(null, msgs, (String) msgs[0], JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE, null, null, null);
|
||||
if (result == JOptionPane.NO_OPTION)
|
||||
return;
|
||||
throw new NoShownTaskException("Operation was canceled by user.");
|
||||
|
||||
File versions = new File(service.baseDirectory(), "versions");
|
||||
|
||||
|
||||
@@ -71,16 +71,15 @@ public class HMCLMinecraftService extends IMinecraftService {
|
||||
for (StackTraceElement e : Thread.currentThread().getStackTrace())
|
||||
if ("checkModpack".equals(e.getMethodName()))
|
||||
++show;
|
||||
if (show > 2)
|
||||
if (show > 1)
|
||||
return;
|
||||
if (version().getVersionCount() == 0) {
|
||||
File modpack = new File("modpack.zip");
|
||||
if (modpack.exists()) {
|
||||
TaskWindow.factory().append(ModpackManager.install(modpack, this, null)).create();
|
||||
if (modpack.exists())
|
||||
if (TaskWindow.execute(ModpackManager.install(modpack, this, null)))
|
||||
version().refreshVersions();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void loadVersionSetting(String id) {
|
||||
if (provider.getVersionById(id) == null)
|
||||
|
||||
@@ -271,7 +271,14 @@ public class TaskWindow extends javax.swing.JDialog
|
||||
SwingUtilities.invokeLater(() -> {
|
||||
if (taskList == null || task == null)
|
||||
return;
|
||||
failReasons.add(task.getInfo() + ": " + (null == task.getFailReason() ? "No exception" : (StrUtils.isBlank(task.getFailReason().getLocalizedMessage()) ? task.getFailReason().getClass().getSimpleName() : task.getFailReason().getLocalizedMessage())));
|
||||
String msg = null;
|
||||
if (task.getFailReason() != null && !(task.getFailReason() instanceof NoShownTaskException))
|
||||
if (StrUtils.isBlank(task.getFailReason().getLocalizedMessage()))
|
||||
msg = task.getFailReason().getClass().getSimpleName();
|
||||
else
|
||||
msg = task.getFailReason().getLocalizedMessage();
|
||||
if (msg != null)
|
||||
failReasons.add(task.getInfo() + ": " + msg);
|
||||
pgsTotal.setMaximum(taskList.taskCount());
|
||||
pgsTotal.setValue(pgsTotal.getValue() + 1);
|
||||
int idx = tasks.indexOf(task);
|
||||
|
||||
Reference in New Issue
Block a user