From a52cc8c0939802b55f5ac47f30e0767b9093397b Mon Sep 17 00:00:00 2001 From: huanghongxun Date: Fri, 23 Feb 2018 11:36:44 +0800 Subject: [PATCH] Fixed crash when launching 1.7.10 forge version --- .../main/java/org/jackhuang/hmcl/game/LauncherHelper.java | 3 ++- .../java/org/jackhuang/hmcl/ui/InstallerController.java | 2 +- .../jackhuang/hmcl/download/DefaultDependencyManager.java | 6 +++--- .../java/org/jackhuang/hmcl/download/MaintainTask.java | 8 +++----- .../src/main/java/org/jackhuang/hmcl/game/Version.java | 2 +- 5 files changed, 10 insertions(+), 11 deletions(-) diff --git a/HMCL/src/main/java/org/jackhuang/hmcl/game/LauncherHelper.java b/HMCL/src/main/java/org/jackhuang/hmcl/game/LauncherHelper.java index 9f5fe9c65..9c5e81970 100644 --- a/HMCL/src/main/java/org/jackhuang/hmcl/game/LauncherHelper.java +++ b/HMCL/src/main/java/org/jackhuang/hmcl/game/LauncherHelper.java @@ -25,6 +25,7 @@ import org.jackhuang.hmcl.auth.AuthInfo; import org.jackhuang.hmcl.auth.AuthenticationException; import org.jackhuang.hmcl.auth.ServerDisconnectException; import org.jackhuang.hmcl.download.DefaultDependencyManager; +import org.jackhuang.hmcl.download.MaintainTask; import org.jackhuang.hmcl.launch.*; import org.jackhuang.hmcl.mod.CurseCompletionTask; import org.jackhuang.hmcl.setting.LauncherVisibility; @@ -76,7 +77,7 @@ public final class LauncherHelper { Profile profile = Settings.INSTANCE.getSelectedProfile(); GameRepository repository = profile.getRepository(); DefaultDependencyManager dependencyManager = profile.getDependency(); - Version version = repository.getVersion(selectedVersion); + Version version = repository.getVersion(selectedVersion).resolve(repository); Account account = Settings.INSTANCE.getSelectedAccount(); VersionSetting setting = profile.getVersionSetting(selectedVersion); Optional gameVersion = GameVersion.minecraftVersion(repository.getVersionJar(version)); diff --git a/HMCL/src/main/java/org/jackhuang/hmcl/ui/InstallerController.java b/HMCL/src/main/java/org/jackhuang/hmcl/ui/InstallerController.java index 42e83d96b..9a977dafc 100644 --- a/HMCL/src/main/java/org/jackhuang/hmcl/ui/InstallerController.java +++ b/HMCL/src/main/java/org/jackhuang/hmcl/ui/InstallerController.java @@ -62,7 +62,7 @@ public class InstallerController { Consumer removeAction = x -> { LinkedList newList = new LinkedList<>(version.getLibraries()); newList.remove(library); - new MaintainTask(profile.getRepository(), version.setLibraries(newList)) + new MaintainTask(version.setLibraries(newList)) .then(variables -> new VersionJsonSaveTask(profile.getRepository(), variables.get(MaintainTask.ID))) .with(profile.getRepository().refreshVersionsAsync()) .with(Task.of(Schedulers.javafx(), () -> loadVersion(this.profile, this.versionId))) diff --git a/HMCLCore/src/main/java/org/jackhuang/hmcl/download/DefaultDependencyManager.java b/HMCLCore/src/main/java/org/jackhuang/hmcl/download/DefaultDependencyManager.java index 21a93a7a5..e3442bbb1 100644 --- a/HMCLCore/src/main/java/org/jackhuang/hmcl/download/DefaultDependencyManager.java +++ b/HMCLCore/src/main/java/org/jackhuang/hmcl/download/DefaultDependencyManager.java @@ -84,17 +84,17 @@ public class DefaultDependencyManager extends AbstractDependencyManager { case "forge": return new ForgeInstallTask(this, gameVersion, version, libraryVersion) .then(variables -> new LibrariesUniqueTask(variables.get("version"))) - .then(variables -> new MaintainTask(repository, variables.get("version"))) + .then(variables -> new MaintainTask(variables.get("version"))) .then(variables -> new VersionJsonSaveTask(repository, variables.get("version"))); case "liteloader": return new LiteLoaderInstallTask(this, gameVersion, version, libraryVersion) .then(variables -> new LibrariesUniqueTask(variables.get("version"))) - .then(variables -> new MaintainTask(repository, variables.get("version"))) + .then(variables -> new MaintainTask(variables.get("version"))) .then(variables -> new VersionJsonSaveTask(repository, variables.get("version"))); case "optifine": return new OptiFineInstallTask(this, gameVersion, version, libraryVersion) .then(variables -> new LibrariesUniqueTask(variables.get("version"))) - .then(variables -> new MaintainTask(repository, variables.get("version"))) + .then(variables -> new MaintainTask(variables.get("version"))) .then(variables -> new VersionJsonSaveTask(repository, variables.get("version"))); default: throw new IllegalArgumentException("Library id " + libraryId + " is unrecognized."); diff --git a/HMCLCore/src/main/java/org/jackhuang/hmcl/download/MaintainTask.java b/HMCLCore/src/main/java/org/jackhuang/hmcl/download/MaintainTask.java index 67406e788..709cb38b0 100644 --- a/HMCLCore/src/main/java/org/jackhuang/hmcl/download/MaintainTask.java +++ b/HMCLCore/src/main/java/org/jackhuang/hmcl/download/MaintainTask.java @@ -28,16 +28,14 @@ import java.util.List; public class MaintainTask extends TaskResult { - private final GameRepository repository; private final Version version; private final String id; - public MaintainTask(GameRepository repository, Version version) { - this(repository, version, ID); + public MaintainTask(Version version) { + this(version, ID); } - public MaintainTask(GameRepository repository, Version version, String id) { - this.repository = repository; + public MaintainTask(Version version, String id) { this.version = version; this.id = id; } diff --git a/HMCLCore/src/main/java/org/jackhuang/hmcl/game/Version.java b/HMCLCore/src/main/java/org/jackhuang/hmcl/game/Version.java index 61f0f317e..64623c931 100644 --- a/HMCLCore/src/main/java/org/jackhuang/hmcl/game/Version.java +++ b/HMCLCore/src/main/java/org/jackhuang/hmcl/game/Version.java @@ -167,7 +167,7 @@ public class Version implements Comparable, Validation { jar == null ? parent.jar : jar, assetIndex == null ? parent.assetIndex : assetIndex, assets == null ? parent.assets : assets, - Lang.merge(parent.libraries, this.libraries), + Lang.merge(this.libraries, parent.libraries), Lang.merge(parent.compatibilityRules, this.compatibilityRules), downloads == null ? parent.downloads : downloads, logging == null ? parent.logging : logging,