mirror of
https://github.com/HMCL-dev/HMCL.git
synced 2025-09-16 15:26:27 -04:00
* Fix #2861: MaintainTask 中不应调用 getGameVersion * update * fix checkstyle
This commit is contained in:
parent
030fba4630
commit
08a3850dcf
@ -282,7 +282,7 @@ public class HMCLGameRepository extends DefaultGameRepository {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (LibraryAnalyzer.isModded(this, version)) {
|
if (LibraryAnalyzer.isModded(this, version)) {
|
||||||
LibraryAnalyzer libraryAnalyzer = LibraryAnalyzer.analyze(version, getGameVersion(version).orElse(null));
|
LibraryAnalyzer libraryAnalyzer = LibraryAnalyzer.analyze(version, null);
|
||||||
if (libraryAnalyzer.has(LibraryAnalyzer.LibraryType.FABRIC))
|
if (libraryAnalyzer.has(LibraryAnalyzer.LibraryType.FABRIC))
|
||||||
return VersionIconType.FABRIC.getIcon();
|
return VersionIconType.FABRIC.getIcon();
|
||||||
else if (libraryAnalyzer.has(LibraryAnalyzer.LibraryType.FORGE))
|
else if (libraryAnalyzer.has(LibraryAnalyzer.LibraryType.FORGE))
|
||||||
|
@ -93,7 +93,7 @@ public final class HMCLModpackInstallTask extends Task<Void> {
|
|||||||
public void execute() throws Exception {
|
public void execute() throws Exception {
|
||||||
String json = CompressingUtils.readTextZipEntry(zipFile, "minecraft/pack.json");
|
String json = CompressingUtils.readTextZipEntry(zipFile, "minecraft/pack.json");
|
||||||
Version originalVersion = JsonUtils.GSON.fromJson(json, Version.class).setId(name).setJar(null);
|
Version originalVersion = JsonUtils.GSON.fromJson(json, Version.class).setId(name).setJar(null);
|
||||||
LibraryAnalyzer analyzer = LibraryAnalyzer.analyze(originalVersion, repository.getGameVersion(originalVersion).orElse(null));
|
LibraryAnalyzer analyzer = LibraryAnalyzer.analyze(originalVersion, null);
|
||||||
Task<Version> libraryTask = Task.supplyAsync(() -> originalVersion);
|
Task<Version> libraryTask = Task.supplyAsync(() -> originalVersion);
|
||||||
// reinstall libraries
|
// reinstall libraries
|
||||||
// libraries of Forge and OptiFine should be obtained by installation.
|
// libraries of Forge and OptiFine should be obtained by installation.
|
||||||
|
@ -27,8 +27,6 @@ import javafx.scene.control.Control;
|
|||||||
import javafx.scene.control.Skin;
|
import javafx.scene.control.Skin;
|
||||||
import javafx.scene.image.Image;
|
import javafx.scene.image.Image;
|
||||||
import org.jackhuang.hmcl.download.LibraryAnalyzer;
|
import org.jackhuang.hmcl.download.LibraryAnalyzer;
|
||||||
import org.jackhuang.hmcl.game.HMCLGameRepository;
|
|
||||||
import org.jackhuang.hmcl.game.Version;
|
|
||||||
import org.jackhuang.hmcl.mod.ModpackConfiguration;
|
import org.jackhuang.hmcl.mod.ModpackConfiguration;
|
||||||
import org.jackhuang.hmcl.setting.Profile;
|
import org.jackhuang.hmcl.setting.Profile;
|
||||||
import org.jackhuang.hmcl.util.i18n.I18n;
|
import org.jackhuang.hmcl.util.i18n.I18n;
|
||||||
@ -61,12 +59,10 @@ public class GameItem extends Control {
|
|||||||
this.version = id;
|
this.version = id;
|
||||||
|
|
||||||
// GameVersion.minecraftVersion() is a time-costing job (up to ~200 ms)
|
// GameVersion.minecraftVersion() is a time-costing job (up to ~200 ms)
|
||||||
CompletableFuture.supplyAsync(() -> profile.getRepository().getGameVersion(id).orElse(i18n("message.unknown")), POOL_VERSION_RESOLVE)
|
CompletableFuture.supplyAsync(() -> profile.getRepository().getGameVersion(id), POOL_VERSION_RESOLVE)
|
||||||
.thenAcceptAsync(game -> {
|
.thenAcceptAsync(game -> {
|
||||||
StringBuilder libraries = new StringBuilder(game);
|
StringBuilder libraries = new StringBuilder(game.orElse(i18n("message.unknown")));
|
||||||
HMCLGameRepository repository = profile.getRepository();
|
LibraryAnalyzer analyzer = LibraryAnalyzer.analyze(profile.getRepository().getResolvedPreservingPatchesVersion(id), game.orElse(null));
|
||||||
Version resolved = repository.getResolvedPreservingPatchesVersion(id);
|
|
||||||
LibraryAnalyzer analyzer = LibraryAnalyzer.analyze(resolved, repository.getGameVersion(resolved).orElse(null));
|
|
||||||
for (LibraryAnalyzer.LibraryMark mark : analyzer) {
|
for (LibraryAnalyzer.LibraryMark mark : analyzer) {
|
||||||
String libraryId = mark.getLibraryId();
|
String libraryId = mark.getLibraryId();
|
||||||
String libraryVersion = mark.getLibraryVersion();
|
String libraryVersion = mark.getLibraryVersion();
|
||||||
|
@ -106,7 +106,7 @@ public class DefaultDependencyManager extends AbstractDependencyManager {
|
|||||||
Version original = repository.getVersion(version.getId());
|
Version original = repository.getVersion(version.getId());
|
||||||
Version resolved = original.resolvePreservingPatches(repository);
|
Version resolved = original.resolvePreservingPatches(repository);
|
||||||
|
|
||||||
LibraryAnalyzer analyzer = LibraryAnalyzer.analyze(resolved, repository.getGameVersion(resolved).orElse(null));
|
LibraryAnalyzer analyzer = LibraryAnalyzer.analyze(resolved, gameVersion);
|
||||||
for (LibraryAnalyzer.LibraryType type : LibraryAnalyzer.LibraryType.values()) {
|
for (LibraryAnalyzer.LibraryType type : LibraryAnalyzer.LibraryType.values()) {
|
||||||
if (!analyzer.has(type))
|
if (!analyzer.has(type))
|
||||||
continue;
|
continue;
|
||||||
|
@ -98,7 +98,7 @@ public class MaintainTask extends Task<Version> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private static Version maintainGameWithLaunchWrapper(GameRepository repository, Version version, boolean reorderTweakClass) {
|
private static Version maintainGameWithLaunchWrapper(GameRepository repository, Version version, boolean reorderTweakClass) {
|
||||||
LibraryAnalyzer libraryAnalyzer = LibraryAnalyzer.analyze(version, repository.getGameVersion(version).orElse(null));
|
LibraryAnalyzer libraryAnalyzer = LibraryAnalyzer.analyze(version, null);
|
||||||
VersionLibraryBuilder builder = new VersionLibraryBuilder(version);
|
VersionLibraryBuilder builder = new VersionLibraryBuilder(version);
|
||||||
String mainClass = null;
|
String mainClass = null;
|
||||||
|
|
||||||
@ -147,7 +147,7 @@ public class MaintainTask extends Task<Version> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private static Version maintainGameWithCpwModLauncher(GameRepository repository, Version version) {
|
private static Version maintainGameWithCpwModLauncher(GameRepository repository, Version version) {
|
||||||
LibraryAnalyzer libraryAnalyzer = LibraryAnalyzer.analyze(version, repository.getGameVersion(version).orElse(null));
|
LibraryAnalyzer libraryAnalyzer = LibraryAnalyzer.analyze(version, null);
|
||||||
VersionLibraryBuilder builder = new VersionLibraryBuilder(version);
|
VersionLibraryBuilder builder = new VersionLibraryBuilder(version);
|
||||||
|
|
||||||
if (!libraryAnalyzer.has(FORGE)) return version;
|
if (!libraryAnalyzer.has(FORGE)) return version;
|
||||||
@ -205,7 +205,7 @@ public class MaintainTask extends Task<Version> {
|
|||||||
|
|
||||||
// Fix wrong configurations when launching 1.17+ with Forge.
|
// Fix wrong configurations when launching 1.17+ with Forge.
|
||||||
private static Version maintainGameWithCpwBoostrapLauncher(GameRepository repository, Version version) {
|
private static Version maintainGameWithCpwBoostrapLauncher(GameRepository repository, Version version) {
|
||||||
LibraryAnalyzer libraryAnalyzer = LibraryAnalyzer.analyze(version, repository.getGameVersion(version).orElse(null));
|
LibraryAnalyzer libraryAnalyzer = LibraryAnalyzer.analyze(version, null);
|
||||||
VersionLibraryBuilder builder = new VersionLibraryBuilder(version);
|
VersionLibraryBuilder builder = new VersionLibraryBuilder(version);
|
||||||
|
|
||||||
if (!libraryAnalyzer.has(FORGE) && !libraryAnalyzer.has(NEO_FORGE)) return version;
|
if (!libraryAnalyzer.has(FORGE) && !libraryAnalyzer.has(NEO_FORGE)) return version;
|
||||||
@ -247,7 +247,7 @@ public class MaintainTask extends Task<Version> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private static Version maintainOptiFineLibrary(GameRepository repository, Version version, boolean remove) {
|
private static Version maintainOptiFineLibrary(GameRepository repository, Version version, boolean remove) {
|
||||||
LibraryAnalyzer libraryAnalyzer = LibraryAnalyzer.analyze(version, repository.getGameVersion(version).orElse(null));
|
LibraryAnalyzer libraryAnalyzer = LibraryAnalyzer.analyze(version, null);
|
||||||
List<Library> libraries = new ArrayList<>(version.getLibraries());
|
List<Library> libraries = new ArrayList<>(version.getLibraries());
|
||||||
|
|
||||||
if (libraryAnalyzer.has(OPTIFINE)) {
|
if (libraryAnalyzer.has(OPTIFINE)) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user