mirror of
https://github.com/HMCL-dev/HMCL.git
synced 2025-09-09 11:55:52 -04:00
parent
1275e38995
commit
15c1042991
@ -94,22 +94,11 @@ public class DownloadPage extends Control implements DecoratorPage {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void loadModVersions() {
|
private void loadModVersions() {
|
||||||
File versionJar = StringUtils.isNotBlank(version.getVersion())
|
|
||||||
? version.getProfile().getRepository().getVersionJar(version.getVersion())
|
|
||||||
: null;
|
|
||||||
|
|
||||||
setLoading(true);
|
setLoading(true);
|
||||||
setFailed(false);
|
setFailed(false);
|
||||||
|
|
||||||
Task.supplyAsync(() -> {
|
Task.supplyAsync(() -> {
|
||||||
Stream<RemoteMod.Version> versions = addon.getData().loadVersions(repository);
|
Stream<RemoteMod.Version> versions = addon.getData().loadVersions(repository);
|
||||||
// if (StringUtils.isNotBlank(version.getVersion())) {
|
|
||||||
// Optional<String> gameVersion = GameVersion.minecraftVersion(versionJar);
|
|
||||||
// if (gameVersion.isPresent()) {
|
|
||||||
// return sortVersions(
|
|
||||||
// .filter(file -> file.getGameVersions().contains(gameVersion.get())));
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
return sortVersions(versions);
|
return sortVersions(versions);
|
||||||
}).whenComplete(Schedulers.javafx(), (result, exception) -> {
|
}).whenComplete(Schedulers.javafx(), (result, exception) -> {
|
||||||
if (exception == null) {
|
if (exception == null) {
|
||||||
@ -286,19 +275,27 @@ public class DownloadPage extends Control implements DecoratorPage {
|
|||||||
if (control.version.getProfile() != null && control.version.getVersion() != null) {
|
if (control.version.getProfile() != null && control.version.getVersion() != null) {
|
||||||
HMCLGameRepository repository = control.version.getProfile().getRepository();
|
HMCLGameRepository repository = control.version.getProfile().getRepository();
|
||||||
Version game = repository.getResolvedPreservingPatchesVersion(control.version.getVersion());
|
Version game = repository.getResolvedPreservingPatchesVersion(control.version.getVersion());
|
||||||
LibraryAnalyzer libraryAnalyzer = LibraryAnalyzer.analyze(game, repository.getGameVersion(game).orElse(null));
|
String gameVersion = repository.getGameVersion(game).orElse(null);
|
||||||
libraryAnalyzer.getVersion(LibraryAnalyzer.LibraryType.MINECRAFT).ifPresent(currentGameVersion -> {
|
|
||||||
Set<ModLoaderType> currentGameModLoaders = libraryAnalyzer.getModLoaders();
|
if (gameVersion != null) {
|
||||||
if (control.versions.containsKey(currentGameVersion)) {
|
List<RemoteMod.Version> modVersions = control.versions.get(gameVersion);
|
||||||
control.versions.get(currentGameVersion).stream()
|
if (modVersions != null && !modVersions.isEmpty()) {
|
||||||
.filter(version1 -> version1.getLoaders().isEmpty() || version1.getLoaders().stream().anyMatch(currentGameModLoaders::contains))
|
Set<ModLoaderType> targetLoaders = LibraryAnalyzer.analyze(game, gameVersion).getModLoaders();
|
||||||
.findFirst()
|
|
||||||
.ifPresent(value -> list.getContent().addAll(
|
resolve:
|
||||||
ComponentList.createComponentListTitle(i18n("mods.download.recommend", currentGameVersion)),
|
for (RemoteMod.Version modVersion : modVersions) {
|
||||||
new ModItem(value, control)
|
for (ModLoaderType loader : modVersion.getLoaders()) {
|
||||||
));
|
if (targetLoaders.contains(loader)) {
|
||||||
|
list.getContent().addAll(
|
||||||
|
ComponentList.createComponentListTitle(i18n("mods.download.recommend", gameVersion)),
|
||||||
|
new ModItem(modVersion, control)
|
||||||
|
);
|
||||||
|
break resolve;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (String gameVersion : control.versions.keys().stream()
|
for (String gameVersion : control.versions.keys().stream()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user