Search in sources :

Example 1 with DownloadFileTask

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));
}
Also used : JavaRuntime(net.technicpack.minecraftcore.mojang.java.JavaRuntime) MojangVersion(net.technicpack.minecraftcore.mojang.version.MojangVersion) IFileVerifier(net.technicpack.launchercore.install.verifiers.IFileVerifier) InstallTasksQueue(net.technicpack.launchercore.install.InstallTasksQueue) JavaVersion(net.technicpack.minecraftcore.mojang.version.io.JavaVersion) SHA1FileVerifier(net.technicpack.launchercore.install.verifiers.SHA1FileVerifier) JavaRuntimes(net.technicpack.minecraftcore.mojang.java.JavaRuntimes) DownloadException(net.technicpack.launchercore.exception.DownloadException) Download(net.technicpack.minecraftcore.mojang.version.io.Download) File(java.io.File) DownloadFileTask(net.technicpack.launchercore.install.tasks.DownloadFileTask)

Example 2 with DownloadFileTask

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));
}
Also used : MojangVersion(net.technicpack.minecraftcore.mojang.version.MojangVersion) AssetIndex(net.technicpack.minecraftcore.mojang.version.io.AssetIndex) IFileVerifier(net.technicpack.launchercore.install.verifiers.IFileVerifier) ValidJsonFileVerifier(net.technicpack.launchercore.install.verifiers.ValidJsonFileVerifier) InstallTasksQueue(net.technicpack.launchercore.install.InstallTasksQueue) SHA1FileVerifier(net.technicpack.launchercore.install.verifiers.SHA1FileVerifier) File(java.io.File) DownloadFileTask(net.technicpack.launchercore.install.tasks.DownloadFileTask)

Example 3 with DownloadFileTask

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;
    }
}
Also used : LauncherResource(net.technicpack.autoupdate.io.LauncherResource) RestfulAPIException(net.technicpack.rest.RestfulAPIException) DownloadException(net.technicpack.launchercore.exception.DownloadException) IFileVerifier(net.technicpack.launchercore.install.verifiers.IFileVerifier) File(java.io.File) DownloadFileTask(net.technicpack.launchercore.install.tasks.DownloadFileTask) StreamVersion(net.technicpack.autoupdate.io.StreamVersion) MD5FileVerifier(net.technicpack.launchercore.install.verifiers.MD5FileVerifier)

Aggregations

File (java.io.File)3 DownloadFileTask (net.technicpack.launchercore.install.tasks.DownloadFileTask)3 IFileVerifier (net.technicpack.launchercore.install.verifiers.IFileVerifier)3 DownloadException (net.technicpack.launchercore.exception.DownloadException)2 InstallTasksQueue (net.technicpack.launchercore.install.InstallTasksQueue)2 SHA1FileVerifier (net.technicpack.launchercore.install.verifiers.SHA1FileVerifier)2 MojangVersion (net.technicpack.minecraftcore.mojang.version.MojangVersion)2 LauncherResource (net.technicpack.autoupdate.io.LauncherResource)1 StreamVersion (net.technicpack.autoupdate.io.StreamVersion)1 MD5FileVerifier (net.technicpack.launchercore.install.verifiers.MD5FileVerifier)1 ValidJsonFileVerifier (net.technicpack.launchercore.install.verifiers.ValidJsonFileVerifier)1 JavaRuntime (net.technicpack.minecraftcore.mojang.java.JavaRuntime)1 JavaRuntimes (net.technicpack.minecraftcore.mojang.java.JavaRuntimes)1 AssetIndex (net.technicpack.minecraftcore.mojang.version.io.AssetIndex)1 Download (net.technicpack.minecraftcore.mojang.version.io.Download)1 JavaVersion (net.technicpack.minecraftcore.mojang.version.io.JavaVersion)1 RestfulAPIException (net.technicpack.rest.RestfulAPIException)1