mirror of
https://github.com/HMCL-dev/HMCL.git
synced 2025-09-16 15:26:27 -04:00
修复 AdditionalInstallersPage (#2731)
This commit is contained in:
parent
7f7068a556
commit
dd2a09399e
@ -86,36 +86,27 @@ class AdditionalInstallersPage extends InstallersPage {
|
|||||||
protected void reload() {
|
protected void reload() {
|
||||||
LibraryAnalyzer analyzer = LibraryAnalyzer.analyze(version.resolvePreservingPatches(repository));
|
LibraryAnalyzer analyzer = LibraryAnalyzer.analyze(version.resolvePreservingPatches(repository));
|
||||||
String game = analyzer.getVersion(MINECRAFT).orElse(null);
|
String game = analyzer.getVersion(MINECRAFT).orElse(null);
|
||||||
String forge = analyzer.getVersion(FORGE).orElse(null);
|
|
||||||
String neoForge = analyzer.getVersion(NEO_FORGE).orElse(null);
|
|
||||||
String liteLoader = analyzer.getVersion(LITELOADER).orElse(null);
|
|
||||||
String optiFine = analyzer.getVersion(OPTIFINE).orElse(null);
|
|
||||||
String fabric = analyzer.getVersion(FABRIC).orElse(null);
|
|
||||||
String fabricApi = analyzer.getVersion(FABRIC_API).orElse(null);
|
|
||||||
String quilt = analyzer.getVersion(QUILT).orElse(null);
|
|
||||||
String quiltApi = analyzer.getVersion(QUILT_API).orElse(null);
|
|
||||||
|
|
||||||
InstallerItem[] libraries = group.getLibraries();
|
|
||||||
String[] versions = new String[]{game, forge, neoForge, liteLoader, optiFine, fabric, fabricApi, quilt, quiltApi};
|
|
||||||
|
|
||||||
String currentGameVersion = Lang.nonNull(getVersion("game"), game);
|
String currentGameVersion = Lang.nonNull(getVersion("game"), game);
|
||||||
|
|
||||||
boolean compatible = true;
|
boolean compatible = true;
|
||||||
for (int i = 0; i < libraries.length; ++i) {
|
|
||||||
String libraryId = libraries[i].getLibraryId();
|
for (InstallerItem library : group.getLibraries()) {
|
||||||
String libraryVersion = Lang.nonNull(getVersion(libraryId), versions[i]);
|
String libraryId = library.getLibraryId();
|
||||||
boolean alreadyInstalled = versions[i] != null && !(controller.getSettings().get(libraryId) instanceof UpdateInstallerWizardProvider.RemoveVersionAction);
|
String version = analyzer.getVersion(libraryId).orElse(null);
|
||||||
|
String libraryVersion = Lang.requireNonNullElse(getVersion(libraryId), version);
|
||||||
|
boolean alreadyInstalled = version != null && !(controller.getSettings().get(libraryId) instanceof UpdateInstallerWizardProvider.RemoveVersionAction);
|
||||||
if (!"game".equals(libraryId) && currentGameVersion != null && !currentGameVersion.equals(game) && getVersion(libraryId) == null && alreadyInstalled) {
|
if (!"game".equals(libraryId) && currentGameVersion != null && !currentGameVersion.equals(game) && getVersion(libraryId) == null && alreadyInstalled) {
|
||||||
// For third-party libraries, if game version is being changed, and the library is not being reinstalled,
|
// For third-party libraries, if game version is being changed, and the library is not being reinstalled,
|
||||||
// warns the user that we should update the library.
|
// warns the user that we should update the library.
|
||||||
libraries[i].setState(libraryVersion, /* incompatibleWithGame */ true, /* removable */ true);
|
library.setState(libraryVersion, /* incompatibleWithGame */ true, /* removable */ true);
|
||||||
compatible = false;
|
compatible = false;
|
||||||
} else if (alreadyInstalled || getVersion(libraryId) != null) {
|
} else if (alreadyInstalled || getVersion(libraryId) != null) {
|
||||||
libraries[i].setState(libraryVersion, /* incompatibleWithGame */ false, /* removable */ true);
|
library.setState(libraryVersion, /* incompatibleWithGame */ false, /* removable */ true);
|
||||||
} else {
|
} else {
|
||||||
libraries[i].setState(/* libraryVersion */ null, /* incompatibleWithGame */ false, /* removable */ false);
|
library.setState(/* libraryVersion */ null, /* incompatibleWithGame */ false, /* removable */ false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
this.compatible.set(compatible);
|
this.compatible.set(compatible);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user