Search in sources :

Example 1 with GameDownloads

use of net.technicpack.minecraftcore.mojang.version.io.GameDownloads in project LauncherV3 by TechnicPack.

the class InstallMinecraftIfNecessaryTask method runTask.

@Override
public void runTask(InstallTasksQueue queue) throws IOException, InterruptedException {
    super.runTask(queue);
    MojangVersion version = ((InstallTasksQueue<MojangVersion>) queue).getMetadata();
    String url;
    GameDownloads dls = version.getDownloads();
    IFileVerifier verifier = null;
    if (dls != null) {
        url = dls.forClient().getUrl();
        verifier = new SHA1FileVerifier(dls.forClient().getSha1());
    } else {
        url = MojangUtils.getOldVersionDownload(this.minecraftVersion);
        Utils.getLogger().log(Level.SEVERE, "Using legacy Minecraft download! Version id = " + version.getId() + "; parent = " + version.getParentVersion());
        String md5 = Utils.getETag(url);
        if (md5 != null && !md5.isEmpty()) {
            verifier = new MD5FileVerifier(md5);
        } else {
            verifier = new ValidZipFileVerifier();
        }
    }
    File cache = new File(cacheDirectory, "minecraft_" + this.minecraftVersion + ".jar");
    if (!cache.exists() || !verifier.isFileValid(cache)) {
        String output = this.pack.getCacheDir() + File.separator + "minecraft.jar";
        Utils.downloadFile(url, cache.getName(), output, cache, verifier, this);
    }
    MojangUtils.copyMinecraftJar(cache, new File(this.pack.getBinDir(), "minecraft.jar"));
}
Also used : ValidZipFileVerifier(net.technicpack.launchercore.install.verifiers.ValidZipFileVerifier) MojangVersion(net.technicpack.minecraftcore.mojang.version.MojangVersion) IFileVerifier(net.technicpack.launchercore.install.verifiers.IFileVerifier) GameDownloads(net.technicpack.minecraftcore.mojang.version.io.GameDownloads) InstallTasksQueue(net.technicpack.launchercore.install.InstallTasksQueue) SHA1FileVerifier(net.technicpack.launchercore.install.verifiers.SHA1FileVerifier) File(java.io.File) MD5FileVerifier(net.technicpack.launchercore.install.verifiers.MD5FileVerifier)

Aggregations

File (java.io.File)1 InstallTasksQueue (net.technicpack.launchercore.install.InstallTasksQueue)1 IFileVerifier (net.technicpack.launchercore.install.verifiers.IFileVerifier)1 MD5FileVerifier (net.technicpack.launchercore.install.verifiers.MD5FileVerifier)1 SHA1FileVerifier (net.technicpack.launchercore.install.verifiers.SHA1FileVerifier)1 ValidZipFileVerifier (net.technicpack.launchercore.install.verifiers.ValidZipFileVerifier)1 MojangVersion (net.technicpack.minecraftcore.mojang.version.MojangVersion)1 GameDownloads (net.technicpack.minecraftcore.mojang.version.io.GameDownloads)1