feat(auto-installing): download Fabric-API to mod folder.

This commit is contained in:
huanghongxun committed 2021-09-13 00:09:19 +08:00
1 parent 5c9deb129d
commit e821f7cb09
6 files changed
+24 -13

No files matched your search

@@ -34,7 +34,9 @@ import javafx.scene.layout.VBox;
import org.jackhuang.hmcl.download.DownloadProvider;
import org.jackhuang.hmcl.download.RemoteVersion;
import org.jackhuang.hmcl.game.HMCLGameRepository;
import org.jackhuang.hmcl.ui.Controllers;
import org.jackhuang.hmcl.ui.InstallerItem;
import org.jackhuang.hmcl.ui.construct.MessageDialogPane;
import org.jackhuang.hmcl.ui.construct.RequiredValidator;
import org.jackhuang.hmcl.ui.construct.Validator;
import org.jackhuang.hmcl.ui.wizard.WizardController;
@@ -68,6 +70,10 @@ public class InstallersPage extends Control implements WizardPage {
String libraryId = library.getLibraryId();
if (libraryId.equals("game")) continue;
library.action.set(e -> {
if ("fabric-api".equals(libraryId)) {
Controllers.dialog(i18n("install.installer.fabric-api.warning"), i18n("message.warning"), MessageDialogPane.MessageType.WARNING);
}
if (library.incompatibleLibraryName.get() == null)
controller.onNext(new VersionsPage(controller, i18n("install.installer.choose", i18n("install.installer." + libraryId)), gameVersion, downloadProvider, libraryId, () -> controller.onPrev(false)));
});
@@ -343,6 +343,7 @@ install.installer.choose=Choose a %s version
install.installer.depend=Depends on %s
install.installer.fabric=Fabric
install.installer.fabric-api=Fabric API
install.installer.fabric-api.warning=Warning: Fabric API is mod, will be installed into mod directory of the new game. You should now change run directory of the new game, or the Fabric API installation will lost. If you do want to change that settings, you should reinstall Fabric API.
install.installer.forge=Forge
install.installer.game=Minecraft
install.installer.incompatible=Incompatible with %s
@@ -348,6 +348,7 @@ install.installer.choose=選擇 %s 版本
install.installer.depend=需要先安裝 %s
install.installer.fabric=Fabric
install.installer.fabric-api=Fabric API
install.installer.fabric-api.warning=警告:Fabric API 是 Mod,將會被安裝到新遊戲的 Mod 文件夾,請你在安裝遊戲後不要修改當前遊戲的版本隔離/遊戲運行路徑設置,如果你在之後修改了相關設置,Fabric API 需要被重新安裝。
install.installer.forge=Forge
install.installer.game=Minecraft
install.installer.incompatible=與 %s 不相容
@@ -343,6 +343,7 @@ install.installer.choose=选择 %s 版本
install.installer.depend=需要先安装 %s
install.installer.fabric=Fabric
install.installer.fabric-api=Fabric API
install.installer.fabric-api.warning=警告:Fabric API 是 Mod,将会被安装到新游戏的 Mod 文件夹,请你在安装游戏后不要修改当前游戏的版本隔离/游戏运行路径设置,如果你在之后修改了相关设置,Fabric API 需要被重新安装。
install.installer.forge=Forge
install.installer.game=Minecraft
install.installer.incompatible=与 %s 不兼容
@@ -137,7 +137,13 @@ public class DefaultDependencyManager extends AbstractDependencyManager {
removedLibraryVersion.set(version);
return libraryVersion.getInstallTask(this, version);
})
.thenApplyAsync(patch -> removedLibraryVersion.get().addPatch(patch))
.thenApplyAsync(patch -> {
if (patch == null) {
return removedLibraryVersion.get();
} else {
return removedLibraryVersion.get().addPatch(patch);
}
})
.withStage(String.format("hmcl.install.%s:%s", libraryVersion.getLibraryId(), libraryVersion.getSelfVersion()));
}
@@ -18,11 +18,12 @@
package org.jackhuang.hmcl.download.fabric;
import org.jackhuang.hmcl.download.DefaultDependencyManager;
import org.jackhuang.hmcl.download.LibraryAnalyzer;
import org.jackhuang.hmcl.game.*;
import org.jackhuang.hmcl.game.Version;
import org.jackhuang.hmcl.task.FileDownloadTask;
import org.jackhuang.hmcl.task.Task;
import java.util.ArrayList;
import java.io.IOException;
import java.net.URL;
import java.util.Collection;
import java.util.LinkedList;
import java.util.List;
@@ -56,14 +57,9 @@ public final class FabricAPIInstallTask extends Task<Version> {
}
@Override
public void execute() {
List<Library> libraries = new ArrayList<>();
libraries.add(new Library(new Artifact("net", "fabricmc", "fabric-api"), null,
new LibrariesDownloadInfo(new LibraryDownloadInfo(
"net/fabricmc/fabric-api/" + remote.getFullVersion() + "/fabric-api-" + remote.getFullVersion() + ".jar",
remote.getUrls().get(0)))));
setResult(new Version(LibraryAnalyzer.LibraryType.FABRIC_API.getPatchId(), remote.getSelfVersion(), 31000, new Arguments(), null, libraries));
dependencies.add(dependencyManager.checkLibraryCompletionAsync(getResult(), true));
public void execute() throws IOException {
dependencies.add(new FileDownloadTask(
new URL(remote.getUrls().get(0)),
dependencyManager.getGameRepository().getRunDirectory(version.getId()).toPath().resolve("mods").resolve("fabric-api-" + remote.getFullVersion() + ".jar").toFile()));
}
}