From caa77387df3d7466bf82aa1da98e1b56a95b1fe5 Mon Sep 17 00:00:00 2001 From: huangyuhui Date: Fri, 28 Jul 2017 08:45:36 +0800 Subject: [PATCH] Fixed reseting the color at warning mode --- .../org/jackhuang/hmcl/setting/VersionSetting.java | 1 - .../main/java/org/jackhuang/hmcl/ui/MainFrame.java | 2 ++ .../java/org/jackhuang/hmcl/ui/MainPagePanel.java | 2 +- .../jackhuang/hmcl/util/HMCLMinecraftService.java | 2 +- .../org/jackhuang/hmcl/api/game/LaunchOptions.java | 9 --------- .../hmcl/core/asset/MinecraftAssetService.java | 13 +++++++------ .../hmcl/core/download/MinecraftRemoteVersions.java | 1 - .../hmcl/core/install/InstallerVersionList.java | 2 +- .../install/forge/MinecraftForgeVersionList.java | 3 +-- .../hmcl/core/launch/AbstractMinecraftLoader.java | 2 +- .../jackhuang/hmcl/core/launch/GameLauncher.java | 2 +- .../jackhuang/hmcl/core/launch/MinecraftLoader.java | 2 +- .../hmcl/core/service/IMinecraftProvider.java | 2 +- .../hmcl/core/version/MinecraftVersionManager.java | 5 +++-- .../java/org/jackhuang/hmcl/util/task/TaskList.java | 2 +- 15 files changed, 21 insertions(+), 29 deletions(-) diff --git a/HMCL/src/main/java/org/jackhuang/hmcl/setting/VersionSetting.java b/HMCL/src/main/java/org/jackhuang/hmcl/setting/VersionSetting.java index f2f2a1ca7..8e6e668d3 100644 --- a/HMCL/src/main/java/org/jackhuang/hmcl/setting/VersionSetting.java +++ b/HMCL/src/main/java/org/jackhuang/hmcl/setting/VersionSetting.java @@ -310,7 +310,6 @@ public class VersionSetting { x.setFullscreen(isFullscreen()); x.setWrapper(getWrapper()); x.setGameDir(gameDir); - x.setGameDirType(getGameDirType()); x.setHeight(getHeight()); x.setJavaArgs(getJavaArgs()); x.setLaunchVersion(id); diff --git a/HMCL/src/main/java/org/jackhuang/hmcl/ui/MainFrame.java b/HMCL/src/main/java/org/jackhuang/hmcl/ui/MainFrame.java index c24ec0c92..383a6fadc 100755 --- a/HMCL/src/main/java/org/jackhuang/hmcl/ui/MainFrame.java +++ b/HMCL/src/main/java/org/jackhuang/hmcl/ui/MainFrame.java @@ -394,6 +394,8 @@ public final class MainFrame extends DraggableFrame implements IRepaint { } public void reloadColor(Theme t) { + if (isShowedMessage) + return; for (Map.Entry entry : t.settings.entrySet()) { if (entry.getValue().startsWith("#")) UIManager.put(entry.getKey(), GraphicsUtils.getWebColor(entry.getValue())); diff --git a/HMCL/src/main/java/org/jackhuang/hmcl/ui/MainPagePanel.java b/HMCL/src/main/java/org/jackhuang/hmcl/ui/MainPagePanel.java index 8df0fd9c1..b05d49386 100755 --- a/HMCL/src/main/java/org/jackhuang/hmcl/ui/MainPagePanel.java +++ b/HMCL/src/main/java/org/jackhuang/hmcl/ui/MainPagePanel.java @@ -402,7 +402,7 @@ public class MainPagePanel extends Page { fc.showOpenDialog(this); if (fc.getSelectedFile() == null) return; - String suggestedModpackId = JOptionPane.showInputDialog("Please enter your favourite game name", FileUtils.getBaseName(fc.getSelectedFile().getName())); + String suggestedModpackId = JOptionPane.showInputDialog(C.i18n("modpack.enter_name"), FileUtils.getBaseName(fc.getSelectedFile().getName())); TaskWindow.factory().append(ModpackManager.install(MainFrame.INSTANCE, fc.getSelectedFile(), Settings.getLastProfile().service(), suggestedModpackId)).execute(); Settings.getLastProfile().service().version().refreshVersions(); }//GEN-LAST:event_btnImportModpackActionPerformed diff --git a/HMCL/src/main/java/org/jackhuang/hmcl/util/HMCLMinecraftService.java b/HMCL/src/main/java/org/jackhuang/hmcl/util/HMCLMinecraftService.java index a59611be5..fe726a85f 100644 --- a/HMCL/src/main/java/org/jackhuang/hmcl/util/HMCLMinecraftService.java +++ b/HMCL/src/main/java/org/jackhuang/hmcl/util/HMCLMinecraftService.java @@ -56,7 +56,7 @@ public class HMCLMinecraftService extends IMinecraftService { public HMCLMinecraftService(Profile p) { this.p = p; this.provider = new HMCLGameProvider(this); - provider.initializeMiencraft(); + provider.initializeMinecraft(); HMCLApi.EVENT_BUS.channel(RefreshingVersionsEvent.class).register(versionSettings::clear); HMCLApi.EVENT_BUS.channel(RefreshedVersionsEvent.class).registerFirst(() -> { if (!checkingModpack) { diff --git a/HMCLAPI/src/main/java/org/jackhuang/hmcl/api/game/LaunchOptions.java b/HMCLAPI/src/main/java/org/jackhuang/hmcl/api/game/LaunchOptions.java index cc9f295d0..1a17e5193 100644 --- a/HMCLAPI/src/main/java/org/jackhuang/hmcl/api/game/LaunchOptions.java +++ b/HMCLAPI/src/main/java/org/jackhuang/hmcl/api/game/LaunchOptions.java @@ -29,7 +29,6 @@ public class LaunchOptions { private String proxyHost, proxyPort, proxyUser, proxyPass, javaDir, launchVersion, type, precalledCommand; private boolean fullscreen, noJVMArgs, notCheckGame; private File gameDir; - private GameDirType gameDirType; public String getVersionName() { return versionName; @@ -115,14 +114,6 @@ public class LaunchOptions { this.fullscreen = fullscreen; } - public GameDirType getGameDirType() { - return gameDirType; - } - - public void setGameDirType(GameDirType gameDirType) { - this.gameDirType = gameDirType; - } - public String getPermSize() { return permSize; } diff --git a/HMCLCore/src/main/java/org/jackhuang/hmcl/core/asset/MinecraftAssetService.java b/HMCLCore/src/main/java/org/jackhuang/hmcl/core/asset/MinecraftAssetService.java index ff569d270..58b2aa237 100644 --- a/HMCLCore/src/main/java/org/jackhuang/hmcl/core/asset/MinecraftAssetService.java +++ b/HMCLCore/src/main/java/org/jackhuang/hmcl/core/asset/MinecraftAssetService.java @@ -120,6 +120,7 @@ public class MinecraftAssetService extends IMinecraftAssetService { HMCLog.warn("Failed to make directories: " + assetsDir); File assetsIndex = getIndexFile(assetIndex.getId()); File renamed = null; + // This is unnecessary to do such backup job, FileDownloadTask can do this. if (assetsIndex.exists()) { renamed = new File(assetsDir, "indexes/" + assetIndex.getId() + "-renamed.json"); if (assetsIndex.renameTo(renamed)) @@ -150,16 +151,16 @@ public class MinecraftAssetService extends IMinecraftAssetService { @Override public File getAssetObject(String assetId, String name) throws IOException { try { - AssetsIndex index = (AssetsIndex) C.GSON.fromJson(FileUtils.read(getIndexFile(assetId), "UTF-8"), AssetsIndex.class); + AssetsIndex index = C.GSON.fromJson(FileUtils.read(getIndexFile(assetId), "UTF-8"), AssetsIndex.class); if (index == null || index.getFileMap() == null || index.getFileMap().get(name) == null) throw new IOException("Assets file format malformed."); - return getAssetObject(assetId, (AssetsObject) index.getFileMap().get(name)); + return getAssetObject(assetId, index.getFileMap().get(name)); } catch (JsonSyntaxException e) { throw new IOException("Assets file format malformed.", e); } } - protected boolean checkAssetsExistance(AssetIndexDownloadInfo assetIndex, LoggingInfo info) { + protected boolean checkAssetsExistence(AssetIndexDownloadInfo assetIndex, LoggingInfo info) { String assetId = assetIndex.getId(); File indexFile = getIndexFile(assetId); File assetDir = getAssets(assetId); @@ -208,8 +209,8 @@ public class MinecraftAssetService extends IMinecraftAssetService { HMCLog.log("Reconstructing virtual assets folder at " + virtualRoot); int tot = index.getFileMap().entrySet().size(); for (Map.Entry entry : index.getFileMap().entrySet()) { - File target = new File(virtualRoot, (String) entry.getKey()); - File original = assetObjectPath(assetsDir, (AssetsObject) entry.getValue()); + File target = new File(virtualRoot, entry.getKey()); + File original = assetObjectPath(assetsDir, entry.getValue()); if (original.exists()) { cnt++; if (!target.isFile()) @@ -240,7 +241,7 @@ public class MinecraftAssetService extends IMinecraftAssetService { LoggingInfo logging = null; if (t.logging != null) logging = t.logging.get("client"); - if (allow && !checkAssetsExistance(t.getAssetsIndex(), logging)) + if (allow && !checkAssetsExistence(t.getAssetsIndex(), logging)) if (MessageBox.show(C.i18n("assets.no_assets"), MessageBox.YES_NO_OPTION) == MessageBox.YES_OPTION) TaskWindow.factory().execute(downloadAssets(t)); return reconstructAssets(t.getAssetsIndex()).getAbsolutePath(); diff --git a/HMCLCore/src/main/java/org/jackhuang/hmcl/core/download/MinecraftRemoteVersions.java b/HMCLCore/src/main/java/org/jackhuang/hmcl/core/download/MinecraftRemoteVersions.java index b788e7b7a..9eb1e03e8 100644 --- a/HMCLCore/src/main/java/org/jackhuang/hmcl/core/download/MinecraftRemoteVersions.java +++ b/HMCLCore/src/main/java/org/jackhuang/hmcl/core/download/MinecraftRemoteVersions.java @@ -23,7 +23,6 @@ import java.util.Arrays; import java.util.Collection; import org.jackhuang.hmcl.util.C; import org.jackhuang.hmcl.util.net.HTTPGetTask; -import org.jackhuang.hmcl.util.net.NetUtils; import org.jackhuang.hmcl.util.task.Task; import org.jackhuang.hmcl.util.task.TaskWorker; diff --git a/HMCLCore/src/main/java/org/jackhuang/hmcl/core/install/InstallerVersionList.java b/HMCLCore/src/main/java/org/jackhuang/hmcl/core/install/InstallerVersionList.java index d7ee07f98..c69cd07a6 100644 --- a/HMCLCore/src/main/java/org/jackhuang/hmcl/core/install/InstallerVersionList.java +++ b/HMCLCore/src/main/java/org/jackhuang/hmcl/core/install/InstallerVersionList.java @@ -59,7 +59,7 @@ public abstract class InstallerVersionList { * * @return cached result. */ - public List getVersionsImpl(String mcVersion) { + private List getVersionsImpl(String mcVersion) { if (versions == null || versionMap == null) return null; if (StrUtils.isBlank(mcVersion)) diff --git a/HMCLCore/src/main/java/org/jackhuang/hmcl/core/install/forge/MinecraftForgeVersionList.java b/HMCLCore/src/main/java/org/jackhuang/hmcl/core/install/forge/MinecraftForgeVersionList.java index 83abe9d4f..95e4f9ce7 100644 --- a/HMCLCore/src/main/java/org/jackhuang/hmcl/core/install/forge/MinecraftForgeVersionList.java +++ b/HMCLCore/src/main/java/org/jackhuang/hmcl/core/install/forge/MinecraftForgeVersionList.java @@ -78,7 +78,6 @@ public class MinecraftForgeVersionList extends InstallerVersionList { MinecraftForgeVersion v = root.number.get(num); InstallerVersion iv = new InstallerVersion(v.version, StrUtils.formatVersion(v.mcversion)); for (String[] f : v.files) { - String ver = v.mcversion + "-" + v.version; if (!StrUtils.isBlank(v.branch)) ver = ver + "-" + v.branch; @@ -105,7 +104,7 @@ public class MinecraftForgeVersionList extends InstallerVersionList { versions.add(iv); } - versionMap.put(StrUtils.formatVersion(mcver), al); + versionMap.put(mcver, al); } Collections.sort(versions, new InstallerVersionComparator()); diff --git a/HMCLCore/src/main/java/org/jackhuang/hmcl/core/launch/AbstractMinecraftLoader.java b/HMCLCore/src/main/java/org/jackhuang/hmcl/core/launch/AbstractMinecraftLoader.java index 11bafaadd..e94e80b8e 100644 --- a/HMCLCore/src/main/java/org/jackhuang/hmcl/core/launch/AbstractMinecraftLoader.java +++ b/HMCLCore/src/main/java/org/jackhuang/hmcl/core/launch/AbstractMinecraftLoader.java @@ -177,7 +177,7 @@ public abstract class AbstractMinecraftLoader implements IMinecraftLoader { if (StrUtils.isNotBlank(options.getProxyUser()) && StrUtils.isNotBlank(options.getProxyPass())) { res.add("--proxyUser"); res.add(options.getProxyUser()); - res.add("-=proxyPass"); + res.add("--proxyPass"); res.add(options.getProxyPass()); } } diff --git a/HMCLCore/src/main/java/org/jackhuang/hmcl/core/launch/GameLauncher.java b/HMCLCore/src/main/java/org/jackhuang/hmcl/core/launch/GameLauncher.java index 313b291ba..bf8f0c3bd 100644 --- a/HMCLCore/src/main/java/org/jackhuang/hmcl/core/launch/GameLauncher.java +++ b/HMCLCore/src/main/java/org/jackhuang/hmcl/core/launch/GameLauncher.java @@ -194,7 +194,7 @@ public abstract class GameLauncher { boolean isWin = OS.os() == OS.WINDOWS; File f = new File(launcherName + (isWin ? ".bat" : ".sh")); if (!f.exists() && !f.createNewFile()) - HMCLog.warn("Failed to create " + f); + throw new IOException("Script file " + f.getAbsolutePath() + " does not exist but cannot be created."); BufferedWriter writer; try (FileOutputStream fos = FileUtils.openOutputStream(f)) { writer = new BufferedWriter(new OutputStreamWriter(fos, Charsets.toCharset())); diff --git a/HMCLCore/src/main/java/org/jackhuang/hmcl/core/launch/MinecraftLoader.java b/HMCLCore/src/main/java/org/jackhuang/hmcl/core/launch/MinecraftLoader.java index d096830e2..8a6af8119 100644 --- a/HMCLCore/src/main/java/org/jackhuang/hmcl/core/launch/MinecraftLoader.java +++ b/HMCLCore/src/main/java/org/jackhuang/hmcl/core/launch/MinecraftLoader.java @@ -65,7 +65,7 @@ public class MinecraftLoader extends AbstractMinecraftLoader { } File f = version.getJar(service.baseDirectory()); if (!f.exists()) - throw new GameException("Minecraft jar does not exists"); + throw new GameException("Minecraft jar does not exist"); library.append(f.getAbsolutePath()).append(File.pathSeparator); res.add("-cp"); res.add(library.toString().substring(0, library.length() - File.pathSeparator.length())); diff --git a/HMCLCore/src/main/java/org/jackhuang/hmcl/core/service/IMinecraftProvider.java b/HMCLCore/src/main/java/org/jackhuang/hmcl/core/service/IMinecraftProvider.java index 1f16c1a08..0dc4a16c0 100644 --- a/HMCLCore/src/main/java/org/jackhuang/hmcl/core/service/IMinecraftProvider.java +++ b/HMCLCore/src/main/java/org/jackhuang/hmcl/core/service/IMinecraftProvider.java @@ -44,7 +44,7 @@ public abstract class IMinecraftProvider { /** * To download mod packs. */ - public abstract void initializeMiencraft(); + public abstract void initializeMinecraft(); /** * Get the run directory of given version. diff --git a/HMCLCore/src/main/java/org/jackhuang/hmcl/core/version/MinecraftVersionManager.java b/HMCLCore/src/main/java/org/jackhuang/hmcl/core/version/MinecraftVersionManager.java index 589a51cc8..73b6fa215 100644 --- a/HMCLCore/src/main/java/org/jackhuang/hmcl/core/version/MinecraftVersionManager.java +++ b/HMCLCore/src/main/java/org/jackhuang/hmcl/core/version/MinecraftVersionManager.java @@ -108,7 +108,7 @@ public class MinecraftVersionManager extends IMinec if (ask) { HMCLog.warn("Found not matched filenames version: " + id + ", json: " + jsons[0].getName()); if (MessageBox.show(String.format(C.i18n("launcher.versions_json_not_matched"), id, jsons[0].getName()), MessageBox.YES_NO_OPTION) == MessageBox.YES_OPTION) - if (!jsons[0].renameTo(new File(jsons[0].getParent(), id + ".json"))) + if (!jsons[0].renameTo(jsonFile)) HMCLog.warn("Failed to rename version json " + jsons[0]); } if (!jsonFile.exists()) { @@ -283,6 +283,7 @@ public class MinecraftVersionManager extends IMinec @Override public boolean onLaunch(String id) { + // Fix bug in Minecraft 1.8 File resourcePacks = new File(getRunDirectory(id), "resourcepacks"); if (!FileUtils.makeDirectory(resourcePacks)) HMCLog.warn("Failed to make resourcePacks: " + resourcePacks); @@ -305,6 +306,6 @@ public class MinecraftVersionManager extends IMinec } @Override - public void initializeMiencraft() { + public void initializeMinecraft() { } } diff --git a/HMCLCore/src/main/java/org/jackhuang/hmcl/util/task/TaskList.java b/HMCLCore/src/main/java/org/jackhuang/hmcl/util/task/TaskList.java index ef9fe2c99..4b89d7a57 100644 --- a/HMCLCore/src/main/java/org/jackhuang/hmcl/util/task/TaskList.java +++ b/HMCLCore/src/main/java/org/jackhuang/hmcl/util/task/TaskList.java @@ -103,7 +103,7 @@ public class TaskList extends Thread { } Invoker thread = new Invoker(t2, counter, bool); invokers.add(thread); - if (!EXECUTOR_SERVICE.isShutdown() && !EXECUTOR_SERVICE.isTerminated()) + if (!EXECUTOR_SERVICE.isShutdown()) futures.put(thread, EXECUTOR_SERVICE.submit(thread)); } try {