protected boolean downloadModPack (String modPackName, String dir) {
Logger.logInfo("Downloading Mod Pack");
TrackerUtils.sendPageView("net/ftb/tools/ModManager.java", "Modpacks / " + modPackName + " / " + curVersion.replace('_', '.'));
String dynamicLoc = OSUtils.getCacheStorageLocation();
String installPath = Settings.getSettings().getInstallPath();
ModPack pack = ModPack.getSelectedPack();
//clearModsFolder(pack);
String baseLink = (pack.isPrivatePack() ? PRIVATEPACKS + dir + "/" + curVersion + "/" : MODPACKS + dir + "/" + curVersion + "/");
baseDynamic = new File(dynamicLoc, "ModPacks" + sep + dir + sep);
Logger.logDebug("pack dir: " + dir);
Logger.logDebug("dynamicLoc: " + dynamicLoc);
Logger.logDebug("installPath: " + installPath);
Logger.logDebug("baseLink: " + baseLink);
baseDynamic.mkdirs();
String md5 = "";
try {
File packFile = new File(baseDynamic, modPackName);
if (!dir.equals("mojang_vanilla") && (!packFile.exists() || !DownloadUtils.backupIsValid(packFile, baseLink + modPackName))) {
try {
new File(baseDynamic, modPackName).createNewFile();
md5 = downloadUrl(baseDynamic.getPath() + sep + modPackName, DownloadUtils.getCreeperhostLink(baseLink + modPackName));
} catch (IOException e) {
Logger.logWarn("Error while downloading modpack", e);
}
String animation = pack.getAnimation();
File animationFile = new File(baseDynamic.getPath() + sep + animation);
if (!animation.equalsIgnoreCase("empty") && !animationFile.exists()) {
downloadUrl(baseDynamic.getPath() + sep + animation, DownloadUtils.getCreeperhostLink(baseLink + animation));
}
}
} catch (Exception e) {
Logger.logError("Error validating pack archive", e);
}
try {
if (!dir.equals("mojang_vanilla")
&& ((md5 == null || md5.isEmpty()) ? DownloadUtils.backupIsValid(new File(baseDynamic, modPackName), baseLink + modPackName) : DownloadUtils.isValid(new File(baseDynamic,
modPackName), md5))) {
Logger.logDebug("Extracting pack.");
Logger.logDebug("Purging mods, coremods, instMods");
clearModsFolder(pack);
FTBFileUtils.delete(new File(installPath, dir + "/minecraft/coremods"));
FTBFileUtils.delete(new File(installPath, dir + "/instMods/"));
boolean saveExists = false;
if (pack.getBundledMap()) {
try {
if (new File(installPath, dir + "/minecraft/saves").exists()) {
saveExists = true;
FTBFileUtils.delete(new File(installPath, dir + "/minecraft/saves.ftbtmp"));
FTBFileUtils.copyFolder(new File(installPath, dir + "/minecraft/saves"), new File(installPath, dir + "/minecraft/saves.ftbtmp"), true);
}
} catch (Exception e) {
Logger.logError("error backing up map", e);
}
}
Logger.logDebug("Extracting pack.");
FTBFileUtils.extractZipTo(baseDynamic.getPath() + sep + modPackName, baseDynamic.getPath());
if (pack.getBundledMap() && saveExists) {
try {
if (new File(installPath, dir + "/minecraft/saves").exists() && new File(installPath, dir + "/minecraft/saves.ftbtmp").exists()) {
FTBFileUtils.delete(new File(installPath, dir + "/minecraft/saves"));
}
if (new File(installPath, dir + "/minecraft/saves.ftbtmp").exists()) {