Search in sources :

Example 1 with JavaRuntimes

use of net.technicpack.minecraftcore.mojang.java.JavaRuntimes 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)

Aggregations

File (java.io.File)1 DownloadException (net.technicpack.launchercore.exception.DownloadException)1 InstallTasksQueue (net.technicpack.launchercore.install.InstallTasksQueue)1 DownloadFileTask (net.technicpack.launchercore.install.tasks.DownloadFileTask)1 IFileVerifier (net.technicpack.launchercore.install.verifiers.IFileVerifier)1 SHA1FileVerifier (net.technicpack.launchercore.install.verifiers.SHA1FileVerifier)1 JavaRuntime (net.technicpack.minecraftcore.mojang.java.JavaRuntime)1 JavaRuntimes (net.technicpack.minecraftcore.mojang.java.JavaRuntimes)1 MojangVersion (net.technicpack.minecraftcore.mojang.version.MojangVersion)1 Download (net.technicpack.minecraftcore.mojang.version.io.Download)1 JavaVersion (net.technicpack.minecraftcore.mojang.version.io.JavaVersion)1