mirror of
https://github.com/HMCL-dev/HMCL.git
synced 2025-09-18 08:16:58 -04:00
Download missing game jar when launching
This commit is contained in:
parent
84636f3f50
commit
c889d7cb3f
@ -19,10 +19,7 @@ package org.jackhuang.hmcl.download;
|
||||
|
||||
import org.jackhuang.hmcl.download.forge.ForgeInstallTask;
|
||||
import org.jackhuang.hmcl.download.forge.ForgeRemoteVersion;
|
||||
import org.jackhuang.hmcl.download.game.GameAssetDownloadTask;
|
||||
import org.jackhuang.hmcl.download.game.GameLibrariesTask;
|
||||
import org.jackhuang.hmcl.download.game.LibrariesUniqueTask;
|
||||
import org.jackhuang.hmcl.download.game.VersionJsonSaveTask;
|
||||
import org.jackhuang.hmcl.download.game.*;
|
||||
import org.jackhuang.hmcl.download.liteloader.LiteLoaderInstallTask;
|
||||
import org.jackhuang.hmcl.download.liteloader.LiteLoaderRemoteVersion;
|
||||
import org.jackhuang.hmcl.download.optifine.OptiFineInstallTask;
|
||||
@ -74,6 +71,12 @@ public class DefaultDependencyManager extends AbstractDependencyManager {
|
||||
@Override
|
||||
public Task checkGameCompletionAsync(Version version) {
|
||||
return new ParallelTask(
|
||||
Task.ofThen(var -> {
|
||||
if (!repository.getVersionJar(version).exists())
|
||||
return new GameDownloadTask(this, null, version);
|
||||
else
|
||||
return null;
|
||||
}),
|
||||
new GameAssetDownloadTask(this, version, GameAssetDownloadTask.DOWNLOAD_INDEX_IF_NECESSARY),
|
||||
new GameLibrariesTask(this, version)
|
||||
);
|
||||
|
@ -56,13 +56,17 @@ public final class GameDownloadTask extends Task {
|
||||
public void execute() {
|
||||
File jar = dependencyManager.getGameRepository().getVersionJar(version);
|
||||
|
||||
dependencies.add(new FileDownloadTask(
|
||||
FileDownloadTask task = new FileDownloadTask(
|
||||
NetworkUtils.toURL(dependencyManager.getDownloadProvider().injectURL(version.getDownloadInfo().getUrl())),
|
||||
jar,
|
||||
IntegrityCheck.of(CacheRepository.SHA1, version.getDownloadInfo().getSha1()))
|
||||
.setCaching(true)
|
||||
.setCacheRepository(dependencyManager.getCacheRepository())
|
||||
.setCandidate(dependencyManager.getCacheRepository().getCommonDirectory().resolve("jars").resolve(gameVersion + ".jar")));
|
||||
.setCacheRepository(dependencyManager.getCacheRepository());
|
||||
|
||||
if (gameVersion != null)
|
||||
task.setCandidate(dependencyManager.getCacheRepository().getCommonDirectory().resolve("jars").resolve(gameVersion + ".jar"));
|
||||
|
||||
dependencies.add(task);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -339,10 +339,6 @@ public abstract class Task {
|
||||
});
|
||||
}
|
||||
|
||||
public static Task empty() {
|
||||
return of(ExceptionalConsumer.empty());
|
||||
}
|
||||
|
||||
public static Task of(String name, ExceptionalRunnable<?> runnable) {
|
||||
return of(name, ExceptionalConsumer.fromRunnable(runnable));
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user