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.tasks.Task;
|
||||||
import org.jackhuang.hellominecraft.util.ui.WebPage;
|
import org.jackhuang.hellominecraft.util.ui.WebPage;
|
||||||
import org.jackhuang.hellominecraft.util.MinecraftVersionRequest;
|
import org.jackhuang.hellominecraft.util.MinecraftVersionRequest;
|
||||||
|
import org.jackhuang.hellominecraft.util.tasks.NoShownTaskException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A mod pack(*.zip) includes these things:
|
* A mod pack(*.zip) includes these things:
|
||||||
@@ -111,7 +112,7 @@ public final class ModpackManager {
|
|||||||
((WebPage) msgs[1]).setPreferredSize(new Dimension(800, 350));
|
((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);
|
int result = JOptionPane.showOptionDialog(null, msgs, (String) msgs[0], JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE, null, null, null);
|
||||||
if (result == JOptionPane.NO_OPTION)
|
if (result == JOptionPane.NO_OPTION)
|
||||||
return;
|
throw new NoShownTaskException("Operation was canceled by user.");
|
||||||
|
|
||||||
File versions = new File(service.baseDirectory(), "versions");
|
File versions = new File(service.baseDirectory(), "versions");
|
||||||
|
|
||||||
|
|||||||
@@ -71,14 +71,13 @@ public class HMCLMinecraftService extends IMinecraftService {
|
|||||||
for (StackTraceElement e : Thread.currentThread().getStackTrace())
|
for (StackTraceElement e : Thread.currentThread().getStackTrace())
|
||||||
if ("checkModpack".equals(e.getMethodName()))
|
if ("checkModpack".equals(e.getMethodName()))
|
||||||
++show;
|
++show;
|
||||||
if (show > 2)
|
if (show > 1)
|
||||||
return;
|
return;
|
||||||
if (version().getVersionCount() == 0) {
|
if (version().getVersionCount() == 0) {
|
||||||
File modpack = new File("modpack.zip");
|
File modpack = new File("modpack.zip");
|
||||||
if (modpack.exists()) {
|
if (modpack.exists())
|
||||||
TaskWindow.factory().append(ModpackManager.install(modpack, this, null)).create();
|
if (TaskWindow.execute(ModpackManager.install(modpack, this, null)))
|
||||||
version().refreshVersions();
|
version().refreshVersions();
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -271,7 +271,14 @@ public class TaskWindow extends javax.swing.JDialog
|
|||||||
SwingUtilities.invokeLater(() -> {
|
SwingUtilities.invokeLater(() -> {
|
||||||
if (taskList == null || task == null)
|
if (taskList == null || task == null)
|
||||||
return;
|
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.setMaximum(taskList.taskCount());
|
||||||
pgsTotal.setValue(pgsTotal.getValue() + 1);
|
pgsTotal.setValue(pgsTotal.getValue() + 1);
|
||||||
int idx = tasks.indexOf(task);
|
int idx = tasks.indexOf(task);
|
||||||
|
|||||||
Reference in New Issue
Block a user