private DownloadStatus notifyStatus(DownloadStatus status) { setChanged(); notifyObservers(status); return status; } }
/** * Downloads a {@link DownloadableFile} moves it to the correct folder. Downloads to the local cache and then * copies to the download folder. * * @param downloadableFile a DownloadableFile with a download URL * @return status of the download, failed, skipped, or success */ public DownloadStatus downloadFile(final DownloadableFile downloadableFile) { return downloadFile(downloadableFile, true); }
@Override public String getCurseforgeWidgetJson() { return reference.getCurseforgeWidgetJsonModpack(); } }
private boolean noProcessArgsSupplied(Arguments arguments) { return !arguments.isDownloadMods() && !arguments.isUpdateMods() && !arguments.isMergeManifests() && StringUtils.isBlank(arguments.getCheckMCUpdate()); }
static boolean isInLocalRepo(final String projectName, final String fileName) { return getLocalFile(fileName, getProjectNameOrDefault(projectName)).exists(); }
private boolean shouldProcessUpdate(Arguments arguments) { return arguments.isUpdateMods() || !StringUtils.isBlank(arguments.getCheckMCUpdate()); }
private String getEncodedDownloadLocation(String projectName, String actualURL, int lastIndexUrl) { String encodedDownloadLocation; if (actualURL.substring(lastIndexUrl).contains(reference.getJarFileExt()) || actualURL.substring(lastIndexUrl).contains(reference.getZipFileExt())) { encodedDownloadLocation = actualURL.substring(lastIndexUrl); } else { encodedDownloadLocation = projectName + reference.getJarFileExt(); } return encodedDownloadLocation; }
private JSONObject getCurseProjectJson(final CurseFile curseFile) throws ParseException, IOException { log.trace("Getting CurseForge Widget JSON..."); val projectId = curseFile.getProjectID(); val projectName = curseFile.getProjectName(); val modOrModPack = curseFile.getCurseforgeWidgetJson(); String urlStr = String.format(reference.getCurseforgeWidgetJsonUrl(), modOrModPack, projectName); log.debug(urlStr); try { return URLHelper.getJsonFromUrl(urlStr); } catch (final FileNotFoundException e) { urlStr = String.format(reference.getCurseforgeWidgetJsonUrl(), modOrModPack, projectId + "-" + projectName); log.debug(urlStr, e); return URLHelper.getJsonFromUrl(urlStr); } }
public String getCurseForgeDownloadUrl() { String baseUrl = curseForge ? reference.getCurseforgeBaseUrl() : reference.getFtbBaseUrl(); return String.format(baseUrl + "%s/files/%s/download", getProjectName(), getFileID()); } }
private JCommander initArguments(final String[] args) { // Initialize application arguments arguments = new Arguments(); return new JCommander(arguments, null, args); } }
public DownloadHelper(Arguments arguments) { this.addObserver(downloadSummarizer); this.arguments = arguments; }
public String getCurseforgeWidgetJson() { return reference.getCurseforgeWidgetJsonMod(); }
private static File getLocalFile(final String fileName, final String newProjectName) { return new File(reference.getUserhome() + newProjectName + File.separator + fileName); }
public UpdateModsProcessor(Arguments arguments, DownloadHelper downloadHelper) { super(arguments, downloadHelper); checkUpdate = !StringUtils.isBlank(arguments.getCheckMCUpdate()); }
public static File getDownloadedFile(final String fileName, String modFolder) { if (modFolder != null) { createFolder(modFolder); return new File(modFolder + File.separator + fileName); } else { return new File(fileName); } }
private void downloadMods(Arguments arguments) throws InterruptedException { if (arguments.isDownloadMods()) { new DownloadModsProcessor(arguments, downloadHelper).process(); } }
private void mergeManifests(Arguments arguments) throws InterruptedException { if (arguments.isMergeManifests()) { new MergeManifestsProcessor(arguments, downloadHelper).process(); } }
static File getLocalFile(DownloadableFile downloadableFile) { return getLocalFile(downloadableFile.getFileName(), downloadableFile.getName()); }
@Override public void downloadMod(final Mod mod) { downloadHelper.downloadFile(mod); }
/** * Initializes arguments and jCommander * * @param args String[] of arguments for execution. See {@link Arguments} for all current parameters */ public ModpackDownloaderManager(String[] args){ arguments = new Arguments(); jCommander = initArguments(args); }