use of net.technicpack.launchercore.install.tasks.DownloadFileTask in project LauncherV3 by TechnicPack.
the class EnsureJavaRuntimeManifestTask method runTask.
@Override
public void runTask(InstallTasksQueue queue) throws IOException {
MojangVersion version = ((InstallTasksQueue<MojangVersion>) queue).getMetadata();
JavaVersion wantedRuntime = version.getJavaVersion();
if (wantedRuntime == null) {
// Nothing to do here, this version doesn't have a Mojang JRE
return;
}
final String runtimeName = wantedRuntime.getComponent();
JavaRuntimes availableRuntimes = MojangUtils.getJavaRuntimes();
if (availableRuntimes == null) {
throw new DownloadException("Failed to get Mojang JRE information");
}
JavaRuntime runtime = availableRuntimes.getRuntimeForCurrentOS(runtimeName);
Download manifest = runtime.getManifest();
File output = new File(runtimesDirectory + File.separator + "manifests", runtimeName + ".json");
(new File(output.getParent())).mkdirs();
IFileVerifier fileVerifier = new SHA1FileVerifier(manifest.getSha1());
if (!output.exists() || !fileVerifier.isFileValid(output)) {
examineJavaQueue.addTask(new DownloadFileTask(manifest.getUrl(), output, fileVerifier));
}
examineJavaQueue.addTask(new InstallJavaRuntimeTask(modpack, runtimesDirectory, output, runtimeName, examineJavaQueue, downloadJavaQueue));
}
use of net.technicpack.launchercore.install.tasks.DownloadFileTask in project LauncherV3 by TechnicPack.
the class EnsureAssetsIndexTask method runTask.
@Override
public void runTask(InstallTasksQueue queue) throws IOException {
MojangVersion version = ((InstallTasksQueue<MojangVersion>) queue).getMetadata();
String assetKey = version.getAssetsKey();
if (assetKey == null || assetKey.isEmpty()) {
assetKey = "legacy";
}
String assetsUrl;
AssetIndex assetIndex = version.getAssetIndex();
if (assetIndex != null) {
assetsUrl = assetIndex.getUrl();
} else {
assetsUrl = MojangUtils.getAssetsIndex(assetKey);
}
File output = new File(assetsDirectory + File.separator + "indexes", assetKey + ".json");
(new File(output.getParent())).mkdirs();
IFileVerifier fileVerifier;
if (assetIndex != null && assetIndex.getSha1() != null)
fileVerifier = new SHA1FileVerifier(assetIndex.getSha1());
else
fileVerifier = new ValidJsonFileVerifier(MojangUtils.getGson());
if (!output.exists() || !fileVerifier.isFileValid(output)) {
downloadIndexQueue.addTask(new DownloadFileTask(assetsUrl, output, fileVerifier));
}
examineIndexQueue.addTask(new InstallMinecraftAssetsTask(modpack, assetsDirectory.getAbsolutePath(), output, checkAssetsQueue, downloadAssetsQueue, installAssetsQueue));
}
use of net.technicpack.launchercore.install.tasks.DownloadFileTask in project LauncherV3 by TechnicPack.
the class QueryUpdateStream method runTask.
@Override
public void runTask(InstallTasksQueue queue) throws IOException, InterruptedException {
try {
StreamVersion version = updateStream.getStreamVersion(relauncher.getStreamName());
if (version == null || version.getBuild() == 0)
return;
for (LauncherResource resource : version.getResources()) {
IFileVerifier verifier = new MD5FileVerifier(resource.getMd5());
File downloadFile = new File(new File(directories.getAssetsDirectory(), "launcher"), resource.getFilename());
if (!downloadFile.exists() || !verifier.isFileValid(downloadFile))
downloadTasks.addTask(new DownloadFileTask(resource.getUrl(), downloadFile, verifier, resource.getFilename()));
}
if (version.getBuild() == relauncher.getCurrentBuild() || (relauncher.getStreamName().startsWith("beta") && version.getBuild() <= relauncher.getCurrentBuild()))
return;
String updateUrl = null;
String runningPath = relauncher.getRunningPath();
if (runningPath == null) {
throw new DownloadException("Could not load a running path for currently-executing launcher.");
}
if (runningPath.endsWith(".exe"))
updateUrl = version.getExeUrl();
else
updateUrl = version.getJarUrl();
downloadTasks.addTask(new DownloadUpdate(updateUrl, relauncher, postDownloadTasks));
} catch (RestfulAPIException ex) {
return;
}
}
Aggregations