Search in sources :

Example 1 with AssetIndex

use of net.technicpack.minecraftcore.mojang.version.io.AssetIndex 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)

Aggregations

File (java.io.File)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 ValidJsonFileVerifier (net.technicpack.launchercore.install.verifiers.ValidJsonFileVerifier)1 MojangVersion (net.technicpack.minecraftcore.mojang.version.MojangVersion)1 AssetIndex (net.technicpack.minecraftcore.mojang.version.io.AssetIndex)1