Download missing game jar when launching
This commit is contained in:
@@ -19,10 +19,7 @@ package org.jackhuang.hmcl.download;
|
|||||||
|
|
||||||
import org.jackhuang.hmcl.download.forge.ForgeInstallTask;
|
import org.jackhuang.hmcl.download.forge.ForgeInstallTask;
|
||||||
import org.jackhuang.hmcl.download.forge.ForgeRemoteVersion;
|
import org.jackhuang.hmcl.download.forge.ForgeRemoteVersion;
|
||||||
import org.jackhuang.hmcl.download.game.GameAssetDownloadTask;
|
import org.jackhuang.hmcl.download.game.*;
|
||||||
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.liteloader.LiteLoaderInstallTask;
|
import org.jackhuang.hmcl.download.liteloader.LiteLoaderInstallTask;
|
||||||
import org.jackhuang.hmcl.download.liteloader.LiteLoaderRemoteVersion;
|
import org.jackhuang.hmcl.download.liteloader.LiteLoaderRemoteVersion;
|
||||||
import org.jackhuang.hmcl.download.optifine.OptiFineInstallTask;
|
import org.jackhuang.hmcl.download.optifine.OptiFineInstallTask;
|
||||||
@@ -74,6 +71,12 @@ public class DefaultDependencyManager extends AbstractDependencyManager {
|
|||||||
@Override
|
@Override
|
||||||
public Task checkGameCompletionAsync(Version version) {
|
public Task checkGameCompletionAsync(Version version) {
|
||||||
return new ParallelTask(
|
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 GameAssetDownloadTask(this, version, GameAssetDownloadTask.DOWNLOAD_INDEX_IF_NECESSARY),
|
||||||
new GameLibrariesTask(this, version)
|
new GameLibrariesTask(this, version)
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -56,13 +56,17 @@ public final class GameDownloadTask extends Task {
|
|||||||
public void execute() {
|
public void execute() {
|
||||||
File jar = dependencyManager.getGameRepository().getVersionJar(version);
|
File jar = dependencyManager.getGameRepository().getVersionJar(version);
|
||||||
|
|
||||||
dependencies.add(new FileDownloadTask(
|
FileDownloadTask task = new FileDownloadTask(
|
||||||
NetworkUtils.toURL(dependencyManager.getDownloadProvider().injectURL(version.getDownloadInfo().getUrl())),
|
NetworkUtils.toURL(dependencyManager.getDownloadProvider().injectURL(version.getDownloadInfo().getUrl())),
|
||||||
jar,
|
jar,
|
||||||
IntegrityCheck.of(CacheRepository.SHA1, version.getDownloadInfo().getSha1()))
|
IntegrityCheck.of(CacheRepository.SHA1, version.getDownloadInfo().getSha1()))
|
||||||
.setCaching(true)
|
.setCaching(true)
|
||||||
.setCacheRepository(dependencyManager.getCacheRepository())
|
.setCacheRepository(dependencyManager.getCacheRepository());
|
||||||
.setCandidate(dependencyManager.getCacheRepository().getCommonDirectory().resolve("jars").resolve(gameVersion + ".jar")));
|
|
||||||
|
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) {
|
public static Task of(String name, ExceptionalRunnable<?> runnable) {
|
||||||
return of(name, ExceptionalConsumer.fromRunnable(runnable));
|
return of(name, ExceptionalConsumer.fromRunnable(runnable));
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user