mirror of
https://github.com/HMCL-dev/HMCL.git
synced 2025-02-05 16:44:47 +08:00
fix: compatibility issue with other launchers using auto-installation
This commit is contained in:
parent
7260ae9b5e
commit
7b6a96b4b6
2
.gitignore
vendored
2
.gitignore
vendored
@ -34,3 +34,5 @@ NVIDIA
|
||||
|
||||
# netbeans
|
||||
.nb-gradle
|
||||
|
||||
*.exe
|
@ -70,6 +70,13 @@ public class MaintainTask extends Task<Version> {
|
||||
}
|
||||
}
|
||||
|
||||
public static Version maintainPreservingPatches(GameRepository repository, Version version) {
|
||||
if (!version.isResolvedPreservingPatches())
|
||||
throw new IllegalArgumentException("MaintainTask requires independent game version");
|
||||
Version newVersion = maintain(repository, version.resolve(repository));
|
||||
return newVersion.setPatches(version.getPatches()).markAsUnresolved();
|
||||
}
|
||||
|
||||
private static Version maintainGameWithLaunchWrapper(Version version) {
|
||||
LibraryAnalyzer libraryAnalyzer = LibraryAnalyzer.analyze(version);
|
||||
VersionLibraryBuilder builder = new VersionLibraryBuilder(version);
|
||||
|
@ -18,6 +18,7 @@
|
||||
package org.jackhuang.hmcl.game;
|
||||
|
||||
import com.google.gson.JsonParseException;
|
||||
import org.jackhuang.hmcl.download.MaintainTask;
|
||||
import org.jackhuang.hmcl.download.game.VersionJsonSaveTask;
|
||||
import org.jackhuang.hmcl.event.Event;
|
||||
import org.jackhuang.hmcl.event.EventBus;
|
||||
@ -393,7 +394,11 @@ public class DefaultGameRepository implements GameRepository {
|
||||
}
|
||||
|
||||
public Task<Version> save(Version version) {
|
||||
return new VersionJsonSaveTask(this, version);
|
||||
if (version.isResolvedPreservingPatches()) {
|
||||
return new VersionJsonSaveTask(this, MaintainTask.maintainPreservingPatches(this, version));
|
||||
} else {
|
||||
return new VersionJsonSaveTask(this, version);
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isLoaded() {
|
||||
|
@ -223,7 +223,7 @@ public class Version implements Comparable<Version>, Validation {
|
||||
*/
|
||||
public Version resolve(VersionProvider provider) throws VersionNotFoundException {
|
||||
if (isResolved()) return this;
|
||||
return resolve(provider, new HashSet<>()).setResolved();
|
||||
return resolve(provider, new HashSet<>()).markAsResolved();
|
||||
}
|
||||
|
||||
protected Version merge(Version parent, boolean isPatch) {
|
||||
@ -243,12 +243,12 @@ public class Version implements Comparable<Version>, Validation {
|
||||
Lang.merge(parent.compatibilityRules, this.compatibilityRules),
|
||||
downloads == null ? parent.downloads : downloads,
|
||||
logging == null ? parent.logging : logging,
|
||||
type,
|
||||
time,
|
||||
releaseTime,
|
||||
type == null ? parent.type : type,
|
||||
time == null ? parent.time : time,
|
||||
releaseTime == null ? parent.releaseTime : releaseTime,
|
||||
Lang.merge(minimumLauncherVersion, parent.minimumLauncherVersion, Math::max),
|
||||
hidden,
|
||||
false,
|
||||
true,
|
||||
isPatch ? parent.patches : Lang.merge(Lang.merge(parent.patches, Collections.singleton(toPatch())), patches));
|
||||
}
|
||||
|
||||
@ -256,7 +256,10 @@ public class Version implements Comparable<Version>, Validation {
|
||||
Version thisVersion;
|
||||
|
||||
if (inheritsFrom == null) {
|
||||
thisVersion = this.jar == null ? this.setJar(id) : this;
|
||||
if (isRoot())
|
||||
thisVersion = new Version(id).setJar(id);
|
||||
else
|
||||
thisVersion = this.jar == null ? this.setJar(id) : this;
|
||||
} else {
|
||||
// To maximize the compatibility.
|
||||
if (!resolvedSoFar.add(id)) {
|
||||
@ -315,10 +318,14 @@ public class Version implements Comparable<Version>, Validation {
|
||||
return thisVersion.setId(id);
|
||||
}
|
||||
|
||||
private Version setResolved() {
|
||||
private Version markAsResolved() {
|
||||
return new Version(true, id, version, priority, minecraftArguments, arguments, mainClass, inheritsFrom, jar, assetIndex, assets, libraries, compatibilityRules, downloads, logging, type, time, releaseTime, minimumLauncherVersion, hidden, root, patches);
|
||||
}
|
||||
|
||||
public Version markAsUnresolved() {
|
||||
return new Version(false, id, version, priority, minecraftArguments, arguments, mainClass, inheritsFrom, jar, assetIndex, assets, libraries, compatibilityRules, downloads, logging, type, time, releaseTime, minimumLauncherVersion, hidden, root, patches);
|
||||
}
|
||||
|
||||
private Version setHidden(Boolean hidden) {
|
||||
return new Version(true, id, version, priority, minecraftArguments, arguments, mainClass, inheritsFrom, jar, assetIndex, assets, libraries, compatibilityRules, downloads, logging, type, time, releaseTime, minimumLauncherVersion, hidden, root, patches);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user