Search in sources :

Example 1 with ModpackZipFilter

use of net.technicpack.minecraftcore.install.ModpackZipFilter in project LauncherV3 by TechnicPack.

the class CleanupAndExtractModpackTask method runTask.

@Override
public void runTask(InstallTasksQueue queue) throws IOException {
    File modsDir = this.pack.getModsDir();
    if (modsDir != null && modsDir.exists()) {
        deleteMods(modsDir);
    }
    File coremodsDir = this.pack.getCoremodsDir();
    if (coremodsDir != null && coremodsDir.exists()) {
        deleteMods(coremodsDir);
    }
    // HACK - jamioflan is a big jerk who needs to put his mods in the dang mod directory!
    File flansDir = new File(this.pack.getInstalledDirectory(), "Flan");
    if (flansDir.exists()) {
        deleteMods(flansDir);
    }
    File packOutput = this.pack.getInstalledDirectory();
    IZipFileFilter zipFilter = new ModpackZipFilter(this.pack);
    for (Mod mod : modpack.getMods()) {
        String url = mod.getUrl();
        String md5 = mod.getMd5();
        String version = mod.getVersion();
        String name;
        if (version != null) {
            name = mod.getName() + "-" + version + ".zip";
        } else {
            name = mod.getName() + ".zip";
        }
        File cache = new File(this.pack.getCacheDir(), name);
        IFileVerifier verifier = null;
        if (md5 != null && !md5.isEmpty())
            verifier = new MD5FileVerifier(md5);
        else
            verifier = new ValidZipFileVerifier();
        checkModQueue.addTask(new EnsureFileTask(cache, verifier, packOutput, url, downloadModQueue, copyModQueue, zipFilter));
    }
    copyModQueue.addTask(new CleanupModpackCacheTask(this.pack, modpack));
}
Also used : EnsureFileTask(net.technicpack.launchercore.install.tasks.EnsureFileTask) ModpackZipFilter(net.technicpack.minecraftcore.install.ModpackZipFilter) Mod(net.technicpack.rest.io.Mod) ValidZipFileVerifier(net.technicpack.launchercore.install.verifiers.ValidZipFileVerifier) IFileVerifier(net.technicpack.launchercore.install.verifiers.IFileVerifier) File(java.io.File) IZipFileFilter(net.technicpack.utilslib.IZipFileFilter) MD5FileVerifier(net.technicpack.launchercore.install.verifiers.MD5FileVerifier)

Aggregations

File (java.io.File)1 EnsureFileTask (net.technicpack.launchercore.install.tasks.EnsureFileTask)1 IFileVerifier (net.technicpack.launchercore.install.verifiers.IFileVerifier)1 MD5FileVerifier (net.technicpack.launchercore.install.verifiers.MD5FileVerifier)1 ValidZipFileVerifier (net.technicpack.launchercore.install.verifiers.ValidZipFileVerifier)1 ModpackZipFilter (net.technicpack.minecraftcore.install.ModpackZipFilter)1 Mod (net.technicpack.rest.io.Mod)1 IZipFileFilter (net.technicpack.utilslib.IZipFileFilter)1