// Path: src/main/java/net/technicpack/minecraftcore/install/tasks/CleanupModpackCacheTask.java
// public class CleanupModpackCacheTask implements IInstallTask {
// 	private ModpackModel pack;
// 	private Modpack modpack;
// 
// 	public CleanupModpackCacheTask(ModpackModel pack, Modpack modpack) {
// 		this.pack = pack;
// 		this.modpack = modpack;
// 	}
// 
// 	@Override
// 	public String getTaskDescription() {
// 		return "Cleaning Modpack Cache";
// 	}
// 
// 	@Override
// 	public float getTaskProgress() {
// 		return 0;
// 	}
// 
// 	@Override
// 	public void runTask(InstallTasksQueue queue) throws IOException {
// 		File[] files = this.pack.getCacheDir().listFiles();
// 
// 		if (files == null) {
// 			return;
// 		}
// 
// 		Set<String> keepFiles = new HashSet<String>(modpack.getMods().size() + 1);
// 		for (Mod mod : modpack.getMods()) {
// 			String version = mod.getVersion();
// 
// 			String name;
// 			if (version != null) {
// 				name = mod.getName() + "-" + version + ".zip";
// 			} else {
// 				name = mod.getName() + ".zip";
// 			}
// 
// 			keepFiles.add(name);
// 		}
// 		keepFiles.add("minecraft.jar");
// 
// 		for (File file : files) {
// 			String fileName = file.getName();
// 			if (keepFiles.contains(fileName)) {
// 				continue;
// 			}
// 			FileUtils.deleteQuietly(file);
// 		}
// 	}
// }


import net.technicpack.launchercore.install.verifiers.ValidZipFileVerifier;
import java.io.File;
import java.io.IOException;
import net.technicpack.launchercore.exception.CacheDeleteException;
import net.technicpack.launchercore.install.ITasksQueue;
import net.technicpack.launchercore.install.InstallTasksQueue;
import net.technicpack.launchercore.install.tasks.EnsureFileTask;
import net.technicpack.launchercore.install.tasks.IInstallTask;
import net.technicpack.launchercore.modpacks.ModpackModel;
import net.technicpack.minecraftcore.install.tasks.CleanupModpackCacheTask;
import net.technicpack.rest.io.Modpack;
import net.technicpack.rest.io.Mod;
import net.technicpack.launchercore.install.verifiers.IFileVerifier;
import net.technicpack.launchercore.install.verifiers.MD5FileVerifier;
		if (flansDir.exists()) {
			deleteMods(flansDir);
		}

		File packOutput = this.pack.getInstalledDirectory();
		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));
		}

// Path: src/main/java/net/technicpack/minecraftcore/install/tasks/CleanupModpackCacheTask.java
// public class CleanupModpackCacheTask implements IInstallTask {
// 	private ModpackModel pack;
// 	private Modpack modpack;
// 
// 	public CleanupModpackCacheTask(ModpackModel pack, Modpack modpack) {
// 		this.pack = pack;
// 		this.modpack = modpack;
// 	}
// 
// 	@Override
// 	public String getTaskDescription() {
// 		return "Cleaning Modpack Cache";
// 	}
// 
// 	@Override
// 	public float getTaskProgress() {
// 		return 0;
// 	}
// 
// 	@Override
// 	public void runTask(InstallTasksQueue queue) throws IOException {
// 		File[] files = this.pack.getCacheDir().listFiles();
// 
// 		if (files == null) {
// 			return;
// 		}
// 
// 		Set<String> keepFiles = new HashSet<String>(modpack.getMods().size() + 1);
// 		for (Mod mod : modpack.getMods()) {
// 			String version = mod.getVersion();
// 
// 			String name;
// 			if (version != null) {
// 				name = mod.getName() + "-" + version + ".zip";
// 			} else {
// 				name = mod.getName() + ".zip";
// 			}
// 
// 			keepFiles.add(name);
// 		}
// 		keepFiles.add("minecraft.jar");
// 
// 		for (File file : files) {
// 			String fileName = file.getName();
// 			if (keepFiles.contains(fileName)) {
// 				continue;
// 			}
// 			FileUtils.deleteQuietly(file);
// 		}
// 	}
// }


// Path: src/main/java/net/technicpack/minecraftcore/install/tasks/InstallModpackTask.java
import net.technicpack.launchercore.install.verifiers.ValidZipFileVerifier;
import java.io.File;
import java.io.IOException;
import net.technicpack.launchercore.exception.CacheDeleteException;
import net.technicpack.launchercore.install.ITasksQueue;
import net.technicpack.launchercore.install.InstallTasksQueue;
import net.technicpack.launchercore.install.tasks.EnsureFileTask;
import net.technicpack.launchercore.install.tasks.IInstallTask;
import net.technicpack.launchercore.modpacks.ModpackModel;
import net.technicpack.minecraftcore.install.tasks.CleanupModpackCacheTask;
import net.technicpack.rest.io.Modpack;
import net.technicpack.rest.io.Mod;
import net.technicpack.launchercore.install.verifiers.IFileVerifier;
import net.technicpack.launchercore.install.verifiers.MD5FileVerifier;

		if (flansDir.exists()) {
			deleteMods(flansDir);
		}

		File packOutput = this.pack.getInstalledDirectory();
		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));
		}

		copyModQueue.addTask(new CleanupModpackCacheTask(this.pack, modpack));