protected void downloadMap(String mapName, String dir) throws IOException, NoSuchAlgorithmException { Logger.logInfo("Downloading"); String installPath = OSUtils.getDynamicStorageLocation(); new File(installPath + "/Maps/" + dir + "/").mkdirs(); new File(installPath + "/Maps/" + dir + "/" + mapName).createNewFile(); downloadUrl( installPath + "/Maps/" + dir + "/" + mapName, DownloadUtils.getCreeperhostLink(mapName)); FileUtils.extractZipTo( installPath + "/Maps/" + dir + "/" + mapName, installPath + "/Maps/" + dir); installMap(mapName, dir); }
private void updateFiles() { Logger.logInfo("[i18n] Downloading locale files ..."); try { DownloadUtils.downloadToFile( new URL(DownloadUtils.getCreeperhostLink("locales.zip")), archive); Logger.logInfo("[i18n] Moving files into place ..."); if (local.getParentFile().exists()) { FileUtils.delete(local.getParentFile()); } FileUtils.extractZipTo(archive.getAbsolutePath(), local.getParentFile().getPath()); if (!local.exists()) { local.createNewFile(); } Writer wr = new FileWriter(local); wr.write(String.valueOf(remoteVer)); wr.close(); cleanUpFiles(); } catch (Exception e) { Logger.logWarn("[i18n] Update IOException", e); } }
protected boolean downloadModPack(String modPackName, String dir) { boolean debugVerbose = Settings.getSettings().getDebugLauncher(); String debugTag = "debug: downloadModPack: "; Logger.logInfo("Downloading Mod Pack"); TrackerUtils.sendPageView( "net/ftb/tools/ModManager.java", "Downloaded: " + modPackName + " v." + curVersion.replace('_', '.')); String dynamicLoc = OSUtils.getDynamicStorageLocation(); String installPath = Settings.getSettings().getInstallPath(); ModPack pack = ModPack.getSelectedPack(); String baseLink = (pack.isPrivatePack() ? "privatepacks/" + dir + "/" + curVersion + "/" : "modpacks/" + dir + "/" + curVersion + "/"); File baseDynamic = new File(dynamicLoc, "ModPacks" + sep + dir + sep); if (debugVerbose) { Logger.logInfo(debugTag + "pack dir: " + dir); Logger.logInfo(debugTag + "dynamicLoc: " + dynamicLoc); Logger.logInfo(debugTag + "installPath: " + installPath); Logger.logInfo(debugTag + "baseLink: " + baseLink); } baseDynamic.mkdirs(); String md5 = ""; try { new File(baseDynamic, modPackName).createNewFile(); md5 = downloadUrl( baseDynamic.getPath() + sep + modPackName, DownloadUtils.getCreeperhostLink(baseLink + modPackName)); } catch (NoSuchAlgorithmException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } String animation = pack.getAnimation(); if (!animation.equalsIgnoreCase("empty")) { try { downloadUrl( baseDynamic.getPath() + sep + animation, DownloadUtils.getCreeperhostLink(baseLink + animation)); } catch (NoSuchAlgorithmException e) { e.printStackTrace(); } } try { if ((md5 == null || md5.isEmpty()) ? DownloadUtils.backupIsValid( new File(baseDynamic, modPackName), baseLink + modPackName) : DownloadUtils.isValid(new File(baseDynamic, modPackName), md5)) { if (debugVerbose) { Logger.logInfo(debugTag + "Extracting pack."); } FileUtils.extractZipTo(baseDynamic.getPath() + sep + modPackName, baseDynamic.getPath()); if (debugVerbose) { Logger.logInfo(debugTag + "Purging mods, coremods, instMods"); } clearModsFolder(pack); FileUtils.delete(new File(installPath, dir + "/minecraft/coremods")); FileUtils.delete(new File(installPath, dir + "/instMods/")); File version = new File(installPath, dir + sep + "version"); BufferedWriter out = new BufferedWriter(new FileWriter(version)); out.write(curVersion.replace("_", ".")); out.flush(); out.close(); if (debugVerbose) { Logger.logInfo(debugTag + "Pack extracted, version tagged."); } return true; } else { ErrorUtils.tossError("Error downloading modpack!!!"); return false; } } catch (IOException e) { e.printStackTrace(); } return false; }