Fixed crash when launching 1.7.10 forge version

This commit is contained in:
huanghongxun 2018-02-23 11:36:44 +08:00
parent 506c409303
commit a52cc8c093
5 changed files with 10 additions and 11 deletions

View File

@ -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<String> gameVersion = GameVersion.minecraftVersion(repository.getVersionJar(version));

View File

@ -62,7 +62,7 @@ public class InstallerController {
Consumer<InstallerItem> removeAction = x -> {
LinkedList<Library> 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)))

View File

@ -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.");

View File

@ -28,16 +28,14 @@ import java.util.List;
public class MaintainTask extends TaskResult<Version> {
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;
}

View File

@ -167,7 +167,7 @@ public class Version implements Comparable<Version>, 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,