allow tasks being hidden in task window
This commit is contained in:
@@ -46,7 +46,7 @@ def buildnumber = System.getenv("TRAVIS_BUILD_NUMBER")
|
||||
if (buildnumber == null)
|
||||
buildnumber = System.getenv("BUILD_NUMBER")
|
||||
if (buildnumber == null)
|
||||
buildnumber = "0"
|
||||
buildnumber = "1"
|
||||
|
||||
def versionroot = System.getenv("VERSION_ROOT")
|
||||
if (versionroot == null)
|
||||
|
||||
@@ -114,7 +114,7 @@ public abstract class IAssetsHandler {
|
||||
try {
|
||||
if (location.exists()) {
|
||||
FileInputStream fis = new FileInputStream(location);
|
||||
String sha = DigestUtils.sha1Hex(IOUtils.getBytesFromStream(fis));
|
||||
String sha = DigestUtils.sha1Hex(IOUtils.readFully(fis).toByteArray());
|
||||
IOUtils.closeQuietly(fis);
|
||||
if (contents.get(i).geteTag().equals(sha)) {
|
||||
++hasDownloaded;
|
||||
|
||||
@@ -24,9 +24,9 @@ import javax.swing.JOptionPane;
|
||||
import org.jackhuang.hellominecraft.util.C;
|
||||
import org.jackhuang.hellominecraft.util.ArrayUtils;
|
||||
import org.jackhuang.hellominecraft.launcher.core.auth.yggdrasil.GameProfile;
|
||||
import org.jackhuang.hellominecraft.launcher.core.auth.yggdrasil.UUIDTypeAdapter;
|
||||
import org.jackhuang.hellominecraft.launcher.core.auth.yggdrasil.PropertyMap;
|
||||
import org.jackhuang.hellominecraft.launcher.core.auth.yggdrasil.YggdrasilAuthentication;
|
||||
import org.jackhuang.hellominecraft.launcher.core.auth.yggdrasil.UUIDTypeAdapter;
|
||||
import org.jackhuang.hellominecraft.util.ui.SwingUtils;
|
||||
|
||||
/**
|
||||
|
||||
@@ -140,7 +140,7 @@ public class YggdrasilAuthentication {
|
||||
|
||||
private void loggedIn(URL url, Object input) throws AuthenticationException {
|
||||
try {
|
||||
String jsonResult = input == null ? NetUtils.get(url) : NetUtils.post(url, GSON.toJson(input), "application/json", proxy);
|
||||
String jsonResult = input == null ? NetUtils.get(url, proxy) : NetUtils.post(url, GSON.toJson(input), "application/json", proxy);
|
||||
Response response = (Response) GSON.fromJson(jsonResult, Response.class);
|
||||
|
||||
if (response == null)
|
||||
|
||||
@@ -21,7 +21,7 @@ import com.google.gson.annotations.SerializedName;
|
||||
import java.util.ArrayList;
|
||||
import org.jackhuang.hellominecraft.util.C;
|
||||
import org.jackhuang.hellominecraft.util.NetUtils;
|
||||
import org.jackhuang.hellominecraft.util.OverridableSwingWorker;
|
||||
import org.jackhuang.hellominecraft.util.AbstractSwingWorker;
|
||||
|
||||
/**
|
||||
*
|
||||
@@ -55,7 +55,7 @@ public class MinecraftRemoteVersions {
|
||||
return new RemoteVersionsTask(type);
|
||||
}
|
||||
|
||||
public static class RemoteVersionsTask extends OverridableSwingWorker<MinecraftRemoteVersion> {
|
||||
public static class RemoteVersionsTask extends AbstractSwingWorker<MinecraftRemoteVersion> {
|
||||
|
||||
DownloadType type;
|
||||
|
||||
|
||||
@@ -28,7 +28,6 @@ import org.jackhuang.hellominecraft.util.logging.HMCLog;
|
||||
import org.jackhuang.hellominecraft.launcher.core.service.IMinecraftService;
|
||||
import org.jackhuang.hellominecraft.util.tasks.Task;
|
||||
import org.jackhuang.hellominecraft.util.system.FileUtils;
|
||||
import org.jackhuang.hellominecraft.util.NetUtils;
|
||||
import org.jackhuang.hellominecraft.launcher.core.version.MinecraftLibrary;
|
||||
import org.jackhuang.hellominecraft.util.MessageBox;
|
||||
import org.jackhuang.hellominecraft.util.system.IOUtils;
|
||||
@@ -55,7 +54,7 @@ public class ForgeInstaller extends Task {
|
||||
|
||||
try (ZipFile zipFile = new ZipFile(forgeInstaller)) {
|
||||
ZipEntry entry = zipFile.getEntry("install_profile.json");
|
||||
String content = IOUtils.getStreamContent(zipFile.getInputStream(entry));
|
||||
String content = IOUtils.toString(zipFile.getInputStream(entry));
|
||||
InstallProfile profile = C.GSON.fromJson(content, InstallProfile.class);
|
||||
File from = new File(gameDir, "versions" + File.separator + profile.install.getMinecraft());
|
||||
if (!from.exists())
|
||||
|
||||
@@ -47,6 +47,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.system.IOUtils;
|
||||
import org.jackhuang.hellominecraft.util.tasks.NoShownTaskException;
|
||||
|
||||
/**
|
||||
@@ -275,8 +276,7 @@ public final class ModpackManager {
|
||||
if (callback != null)
|
||||
callback.call(zip);
|
||||
} finally {
|
||||
if (zip != null)
|
||||
zip.closeFile();
|
||||
IOUtils.closeQuietly(zip);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -160,7 +160,7 @@ public final class Main implements Runnable {
|
||||
HMCLog.warn("Failed to set look and feel...", ex);
|
||||
}
|
||||
|
||||
Settings.UPDATE_CHECKER.outdated.register(IUpgrader.NOW_UPGRADER);
|
||||
Settings.UPDATE_CHECKER.outOfDateEvent.register(IUpgrader.NOW_UPGRADER);
|
||||
Settings.UPDATE_CHECKER.process(false).reg(t -> Main.invokeUpdate()).execute();
|
||||
|
||||
if (StrUtils.isNotBlank(Settings.getInstance().getProxyHost()) && StrUtils.isNotBlank(Settings.getInstance().getProxyPort()) && MathUtils.canParseInt(Settings.getInstance().getProxyPort())) {
|
||||
|
||||
@@ -131,7 +131,7 @@ public final class Settings {
|
||||
}
|
||||
|
||||
public static Collection<Profile> getProfilesFiltered() {
|
||||
return CollectionUtils.map(getProfiles().values(), t -> t != null && t.getName() != null);
|
||||
return CollectionUtils.filter(getProfiles().values(), t -> t != null && t.getName() != null);
|
||||
}
|
||||
|
||||
public static Profile getOneProfile() {
|
||||
|
||||
@@ -107,10 +107,14 @@ public class GameDownloadPanel extends Page {
|
||||
|
||||
public void refreshDownloads() {
|
||||
DefaultTableModel model = SwingUtils.clearDefaultTable(lstDownloads);
|
||||
model.addRow(new Object[] { C.i18n("message.loading"), "", "" });
|
||||
MinecraftRemoteVersions.refreshRomoteVersions(Settings.getLastProfile().service().getDownloadType())
|
||||
.reg((ver) -> model.addRow(new Object[] { ver.id, ver.time,
|
||||
StrUtils.equalsOne(ver.type, "old_beta", "old_alpha", "release", "snapshot") ? C.i18n("versions." + ver.type) : ver.type }))
|
||||
.regDone(lstDownloads::requestFocus).execute();
|
||||
.reg((ver) -> model.addRow(new Object[] { ver.id, ver.time,
|
||||
StrUtils.equalsOne(ver.type, "old_beta", "old_alpha", "release", "snapshot") ? C.i18n("versions." + ver.type) : ver.type }))
|
||||
.regDone(() -> {
|
||||
lstDownloads.requestFocus();
|
||||
model.removeRow(0);
|
||||
}).execute();
|
||||
}
|
||||
|
||||
void downloadMinecraft() {
|
||||
|
||||
@@ -54,7 +54,7 @@ import org.jackhuang.hellominecraft.launcher.core.version.GameDirType;
|
||||
import org.jackhuang.hellominecraft.launcher.core.version.MinecraftVersion;
|
||||
import org.jackhuang.hellominecraft.launcher.setting.VersionSetting;
|
||||
import org.jackhuang.hellominecraft.util.MessageBox;
|
||||
import org.jackhuang.hellominecraft.util.OverridableSwingWorker;
|
||||
import org.jackhuang.hellominecraft.util.AbstractSwingWorker;
|
||||
import org.jackhuang.hellominecraft.util.MinecraftVersionRequest;
|
||||
import org.jackhuang.hellominecraft.util.system.OS;
|
||||
import org.jackhuang.hellominecraft.util.StrUtils;
|
||||
@@ -1276,7 +1276,7 @@ public final class GameSettingsPanel extends RepaintPage implements DropTargetLi
|
||||
}
|
||||
}
|
||||
|
||||
private static class OverridableSwingWorkerImpl extends OverridableSwingWorker<List<ModInfo>> {
|
||||
private static class OverridableSwingWorkerImpl extends AbstractSwingWorker<List<ModInfo>> {
|
||||
|
||||
@Override
|
||||
protected void work() throws Exception {
|
||||
|
||||
@@ -348,7 +348,7 @@ public final class MainFrame extends DraggableFrame implements IRepaint {
|
||||
isShowedMessage = false;
|
||||
reloadColor(Settings.getInstance().getTheme());
|
||||
windowTitle.setText(defaultTitle);
|
||||
windowTitle.setForeground(Settings.UPDATE_CHECKER.OUT_DATED ? Color.red : Color.white);
|
||||
windowTitle.setForeground(Settings.UPDATE_CHECKER.isOutOfDate() ? Color.red : Color.white);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -114,33 +114,33 @@ public class ModpackWizard extends WizardBranchController {
|
||||
boolean including = false;
|
||||
if ((Boolean) settings.get(ModpackInitializationPanel.KEY_INCLUDING_LAUNCHER)) {
|
||||
boolean flag = true;
|
||||
ZipEngine engine = new ZipEngine(loc);
|
||||
Config s = new Config();
|
||||
if (!IOUtils.isAbsolutePath(Settings.getInstance().getBgpath()))
|
||||
s.setBgpath(Settings.getInstance().getBgpath());
|
||||
s.setDownloadType(Settings.getInstance().getDownloadType());
|
||||
engine.putTextFile(C.GSON.toJson(s), "hmcl.json");
|
||||
engine.putFile(modpack, "modpack.zip");
|
||||
File bg = new File("bg");
|
||||
if (bg.isDirectory())
|
||||
engine.putDirectory(bg);
|
||||
bg = new File("background.png");
|
||||
if (bg.isFile())
|
||||
engine.putFile(bg, "background.png");
|
||||
bg = new File("background.jpg");
|
||||
if (bg.isFile())
|
||||
engine.putFile(bg, "background.jpg");
|
||||
for (URL u : Utils.getURL())
|
||||
try {
|
||||
File f = new File(u.toURI());
|
||||
if (f.getName().endsWith(".exe") || f.getName().endsWith(".jar"))
|
||||
engine.putFile(f, f.getName());
|
||||
} catch (IOException | URISyntaxException e) {
|
||||
HMCLog.err("Failed to add launcher files.", e);
|
||||
flag = false;
|
||||
break;
|
||||
}
|
||||
engine.closeFile();
|
||||
try (ZipEngine engine = new ZipEngine(loc)) {
|
||||
Config s = new Config();
|
||||
if (!IOUtils.isAbsolutePath(Settings.getInstance().getBgpath()))
|
||||
s.setBgpath(Settings.getInstance().getBgpath());
|
||||
s.setDownloadType(Settings.getInstance().getDownloadType());
|
||||
engine.putTextFile(C.GSON.toJson(s), "hmcl.json");
|
||||
engine.putFile(modpack, "modpack.zip");
|
||||
File bg = new File("bg");
|
||||
if (bg.isDirectory())
|
||||
engine.putDirectory(bg);
|
||||
bg = new File("background.png");
|
||||
if (bg.isFile())
|
||||
engine.putFile(bg, "background.png");
|
||||
bg = new File("background.jpg");
|
||||
if (bg.isFile())
|
||||
engine.putFile(bg, "background.jpg");
|
||||
for (URL u : Utils.getURL())
|
||||
try {
|
||||
File f = new File(u.toURI());
|
||||
if (f.getName().endsWith(".exe") || f.getName().endsWith(".jar"))
|
||||
engine.putFile(f, f.getName());
|
||||
} catch (IOException | URISyntaxException e) {
|
||||
HMCLog.err("Failed to add launcher files.", e);
|
||||
flag = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (flag) {
|
||||
including = true;
|
||||
if (!modpack.delete())
|
||||
|
||||
@@ -111,8 +111,8 @@ public class CrashReporter implements Thread.UncaughtExceptionHandler {
|
||||
System.out.println(text);
|
||||
|
||||
if (checkThrowable(e) && !System.getProperty("java.vm.name").contains("OpenJDK")) {
|
||||
SwingUtilities.invokeLater(() -> LogWindow.INSTANCE.showAsCrashWindow(Settings.UPDATE_CHECKER.OUT_DATED));
|
||||
if (!Settings.UPDATE_CHECKER.OUT_DATED)
|
||||
SwingUtilities.invokeLater(() -> LogWindow.INSTANCE.showAsCrashWindow(Settings.UPDATE_CHECKER.isOutOfDate()));
|
||||
if (!Settings.UPDATE_CHECKER.isOutOfDate())
|
||||
reportToServer(text, s);
|
||||
}
|
||||
} catch (Throwable ex) {
|
||||
|
||||
Reference in New Issue
Block a user