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

This commit is contained in:
huanghongxun
2021-09-13 00:09:19 +08:00
parent 5c9deb129d
commit e821f7cb09
6 changed files with 24 additions and 13 deletions

View File

@@ -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()));
}

View File

@@ -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()));
}
}