/** Used to load all available download servers in a thread to prevent wait. */ @Override public void run() { downloadServers.put("Automatic", "www.creeperrepo.net"); BufferedReader in = null; try { in = new BufferedReader( new InputStreamReader(new URL("http://www.creeperrepo.net/mirrors").openStream())); String line; while ((line = in.readLine()) != null) { String[] splitString = line.split(","); if (splitString.length == 2) { downloadServers.put(splitString[0], splitString[1]); } } in.close(); } catch (IOException e) { Logger.logError(e.getMessage(), e); } finally { if (in != null) { try { in.close(); } catch (IOException e) { } } } serversLoaded = true; if (LaunchFrame.getInstance() != null && LaunchFrame.getInstance().optionsPane != null) { AdvancedOptionsDialog.setDownloadServers(); } }
@Override public void actionPerformed(ActionEvent e) { JFileChooser chooser = new JFileChooser(); if (optionsPane != null) { chooser.setCurrentDirectory(new File(Settings.getSettings().getInstallPath())); chooser.setDialogTitle(choosertitle); chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY); chooser.setAcceptAllFileFilterUsed(false); if (chooser.showOpenDialog(this) == JFileChooser.APPROVE_OPTION) { Logger.logInfo("getCurrentDirectory(): " + chooser.getCurrentDirectory()); Logger.logInfo("getSelectedFile() : " + chooser.getSelectedFile()); optionsPane.setInstallFolderText(chooser.getSelectedFile().getPath()); } else { Logger.logWarn("No Selection."); } } else if (editMPD != null) { if (!Settings.getSettings().getLastAddPath().isEmpty()) { chooser.setCurrentDirectory(new File(Settings.getSettings().getLastAddPath())); } chooser.setDialogTitle("Please select the mod to install"); chooser.setFileSelectionMode(JFileChooser.FILES_ONLY); chooser.setAcceptAllFileFilterUsed(true); if (chooser.showOpenDialog(this) == JFileChooser.APPROVE_OPTION) { File destination = new File(editMPD.folder, chooser.getSelectedFile().getName()); if (!destination.exists()) { try { FileUtils.copyFile(chooser.getSelectedFile(), destination); Settings.getSettings().setLastAddPath(chooser.getSelectedFile().getPath()); LaunchFrame.getInstance().saveSettings(); } catch (IOException e1) { Logger.logError(e1.getMessage()); } editMPD.updateLists(); } else { ErrorUtils.tossError("File already exists, cannot add mod!"); } } else { Logger.logWarn("No Selection."); } } else { chooser.setCurrentDirectory(new File(Settings.getSettings().getInstallPath())); chooser.setDialogTitle(choosertitle); chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY); chooser.setAcceptAllFileFilterUsed(false); if (chooser.showOpenDialog(this) == JFileChooser.APPROVE_OPTION) { Logger.logInfo("getCurrentDirectory(): " + chooser.getCurrentDirectory()); Logger.logInfo("getSelectedFile() : " + chooser.getSelectedFile()); installDialog.setInstallFolderText(chooser.getSelectedFile().getPath()); } else { Logger.logWarn("No Selection."); } } }
@Override public void onTexturePackAdded(TexturePack texturePack) { Logger.logInfo("Adding texture pack " + TexturePack.size()); filteredPacks.clear(); fireIntervalAdded(this, TexturePack.size() - 1, TexturePack.size()); }