Example #1
0
 @Override
 protected Boolean doInBackground() {
   try {
     if (!upToDate()) {
       String installPath = OSUtils.getDynamicStorageLocation();
       ModPack pack = ModPack.getSelectedPack();
       pack.setUpdated(true);
       File modPackZip =
           new File(installPath, "ModPacks" + sep + pack.getDir() + sep + pack.getUrl());
       if (modPackZip.exists()) {
         FileUtils.delete(modPackZip);
       }
       File animationGif =
           new File(
               OSUtils.getDynamicStorageLocation(),
               "ModPacks" + sep + pack.getDir() + sep + pack.getAnimation());
       if (animationGif.exists()) {
         FileUtils.delete(animationGif);
       }
       String dynamicLoc = OSUtils.getDynamicStorageLocation();
       baseDynamic = new File(dynamicLoc, "ModPacks" + sep + pack.getDir() + sep);
       // clearModsFolder(pack);
       erroneous = !downloadModPack(pack.getUrl(), pack.getDir());
     }
   } catch (IOException e) {
     e.printStackTrace();
   }
   return true;
 }
 boolean avaliabilityCheck(ModPack pack) {
   return (avaliability.equalsIgnoreCase(I18N.getLocaleString("MAIN_ALL")))
       || (avaliability.equalsIgnoreCase(I18N.getLocaleString("FILTER_PUBLIC"))
           && !pack.isPrivatePack())
       || (avaliability.equalsIgnoreCase(I18N.getLocaleString("FILTER_PRIVATE"))
           && pack.isPrivatePack());
 }
 public void filterPacks() {
   packPanels.clear();
   packs.removeAll();
   currentPacks.clear();
   packMapping.clear();
   int counter = 0;
   selectedPack = 0;
   packInfo.setText("");
   // all removed, repaint
   packs.repaint();
   // not really needed
   // modPacksAdded = false;
   for (ModPack pack : ModPack.getPackArray()) {
     if (filterForTab(pack)
         && mcVersionCheck(pack)
         && avaliabilityCheck(pack)
         && textSearch(pack)) {
       currentPacks.put(counter, pack);
       packMapping.put(counter, pack.getIndex());
       addPack(pack);
       counter++;
     }
   }
   updateDatas();
   updatePacks();
 }
Example #4
0
 /**
  * updates the tpInstall to the available ones
  *
  * @param locations - the available locations to install the tp to
  */
 public static void updateTpInstallLocs(String[] locations) {
   tpInstallLocation.removeAllItems();
   for (String location : locations) {
     if (!location.isEmpty()) {
       tpInstallLocation.addItem(ModPack.getPack(location.trim()).getName());
     }
   }
   tpInstallLocation.setSelectedItem(ModPack.getSelectedPack().getName());
 }
Example #5
0
 public void setPackVer(String string) {
   setProperty(ModPack.getSelectedPack().getDir(), string);
   if (ModPack.getSelectedPack().getDir().equals("mojang_vanilla")) {
     ModPack.setVanillaPackMCVersion(
         string.equalsIgnoreCase("Recommended Version")
             ? ModPack.getSelectedPack().getVersion()
             : string);
   }
 }
Example #6
0
 public void doLaunch() {
   if (users.getSelectedIndex() > 1 && ModPack.getSelectedPack() != null) {
     Settings.getSettings().setLastPack(ModPack.getSelectedPack().getDir());
     saveSettings();
     doLogin(
         UserManager.getUsername(users.getSelectedItem().toString()),
         UserManager.getPassword(users.getSelectedItem().toString()));
   } else if (users.getSelectedIndex() <= 1) {
     ErrorUtils.tossError("Please select a profile!");
   }
 }
Example #7
0
 /**
  * Download and install mods
  *
  * @return boolean - represents whether it was successful in initializing mods
  */
 private boolean initializeMods() {
   Logger.logInfo(ModPack.getSelectedPack().getDir());
   ModManager man = new ModManager(new JFrame(), true);
   man.setVisible(true);
   if (man.erroneous) {
     return false;
   }
   try {
     installMods(ModPack.getSelectedPack().getDir());
     man.cleanUp();
   } catch (IOException e) {
   }
   return true;
 }
 private boolean upToDate() throws IOException {
   ModPack pack = ModPack.getSelectedPack();
   File version =
       new File(Settings.getSettings().getInstallPath(), pack.getDir() + sep + "version");
   if (!version.exists()) {
     version.getParentFile().mkdirs();
     version.createNewFile();
     curVersion =
         (Settings.getSettings().getPackVer().equalsIgnoreCase("recommended version")
                 ? pack.getVersion()
                 : Settings.getSettings().getPackVer())
             .replace(".", "_");
     return false;
   }
   BufferedReader in = new BufferedReader(new FileReader(version));
   String line = in.readLine();
   in.close();
   int currentVersion, requestedVersion;
   currentVersion = (line != null) ? Integer.parseInt(line.replace(".", "")) : 0;
   if (!Settings.getSettings().getPackVer().equalsIgnoreCase("recommended version")
       && !Settings.getSettings().getPackVer().equalsIgnoreCase("newest version")) {
     requestedVersion =
         Integer.parseInt(Settings.getSettings().getPackVer().trim().replace(".", ""));
     if (requestedVersion != currentVersion) {
       Logger.logInfo("Modpack is out of date.");
       curVersion = Settings.getSettings().getPackVer().replace(".", "_");
       return false;
     } else {
       Logger.logInfo("Modpack is up to date.");
       return true;
     }
   } else if (Integer.parseInt(pack.getVersion().replace(".", "")) > currentVersion) {
     Logger.logInfo("Modpack is out of date.");
     ModpackUpdateDialog p = new ModpackUpdateDialog(LaunchFrame.getInstance(), true);
     p.setVisible(true);
     if (!update) {
       return true;
     }
     if (backup) {
       File destination =
           new File(
               OSUtils.getDynamicStorageLocation(),
               "backups" + sep + pack.getDir() + sep + "config_backup");
       if (destination.exists()) {
         FileUtils.delete(destination);
       }
       FileUtils.copyFolder(
           new File(
               Settings.getSettings().getInstallPath(),
               pack.getDir() + sep + "minecraft" + sep + "config"),
           destination);
     }
     curVersion = pack.getVersion().replace(".", "_");
     return false;
   } else {
     Logger.logInfo("Modpack is up to date.");
     return true;
   }
 }
 public void updateDatas() {
   currentPacks.clear();
   packMapping.clear();
   int counter = 0;
   // Are we going to save list of modpack there or here?!
   for (ModPack pack : ModPack.getPackArray()) {
     if (filterForTab(pack)
         && mcVersionCheck(pack)
         && avaliabilityCheck(pack)
         && textSearch(pack)) {
       currentPacks.put(counter, pack);
       packMapping.put(counter, pack.getIndex());
       counter++;
     }
   }
 }
Example #10
0
  /** deletes the META-INF */
  public static void killMetaInf() {
    File inputFile =
        new File(
            Settings.getSettings().getInstallPath()
                + "/"
                + ModPack.getSelectedPack().getDir()
                + "/minecraft/bin",
            "minecraft.jar");
    File outputTmpFile =
        new File(
            Settings.getSettings().getInstallPath()
                + "/"
                + ModPack.getSelectedPack().getDir()
                + "/minecraft/bin",
            "minecraft.jar.tmp");
    try {
      JarInputStream input = new JarInputStream(new FileInputStream(inputFile));
      JarOutputStream output = new JarOutputStream(new FileOutputStream(outputTmpFile));
      JarEntry entry;

      while ((entry = input.getNextJarEntry()) != null) {
        if (entry.getName().contains("META-INF")) {
          continue;
        }
        output.putNextEntry(entry);
        byte buffer[] = new byte[1024];
        int amo;
        while ((amo = input.read(buffer, 0, 1024)) != -1) {
          output.write(buffer, 0, amo);
        }
        output.closeEntry();
      }

      input.close();
      output.close();

      if (!inputFile.delete()) {
        Logger.logError("Failed to delete Minecraft.jar.");
        return;
      }
      outputTmpFile.renameTo(inputFile);
    } catch (FileNotFoundException e) {
      Logger.logError(e.getMessage(), e);
    } catch (IOException e) {
      Logger.logError(e.getMessage(), e);
    }
  }
Example #11
0
 private static void sortPacks() {
   packPanels.clear();
   packs.removeAll();
   currentPacks.clear();
   int counter = 0;
   selectedPack = 0;
   packInfo.setText("");
   LaunchFrame.getInstance().modPacksPane.repaint();
   if (origin.equalsIgnoreCase("all")) {
     for (ModPack pack : ModPack.getPackArray()) {
       addPack(pack);
       currentPacks.put(counter, pack);
       counter++;
     }
   } else if (origin.equalsIgnoreCase("ftb")) {
     for (ModPack pack : ModPack.getPackArray()) {
       if (pack.getAuthor().equalsIgnoreCase("the ftb team")) {
         addPack(pack);
         currentPacks.put(counter, pack);
         counter++;
       }
     }
   } else {
     for (ModPack pack : ModPack.getPackArray()) {
       if (!pack.getAuthor().equalsIgnoreCase("the ftb team")) {
         addPack(pack);
         currentPacks.put(counter, pack);
         counter++;
       }
     }
   }
   updatePacks();
 }
Example #12
0
 /**
  * launch the game with the mods in the classpath
  *
  * @param workingDir - install path
  * @param username - the MC username
  * @param password - the MC password
  */
 public void launchMinecraft(String workingDir, String username, String password) {
   try {
     Process minecraftProcess =
         MinecraftLauncher.launchMinecraft(
             workingDir, username, password, FORGENAME, Settings.getSettings().getRamMax());
     StreamLogger.start(minecraftProcess.getInputStream(), new LogEntry().level(LogLevel.UNKNOWN));
     TrackerUtils.sendPageView(
         ModPack.getSelectedPack().getName() + " Launched", ModPack.getSelectedPack().getName());
     try {
       Thread.sleep(1500);
     } catch (InterruptedException e) {
     }
     try {
       minecraftProcess.exitValue();
     } catch (IllegalThreadStateException e) {
       this.setVisible(false);
       ProcessMonitor.create(
           minecraftProcess,
           new Runnable() {
             @Override
             public void run() {
               if (!Settings.getSettings().getKeepLauncherOpen()) {
                 System.exit(0);
               } else {
                 LaunchFrame launchFrame = LaunchFrame.this;
                 launchFrame.setVisible(true);
                 launchFrame.enableObjects();
                 try {
                   Settings.getSettings()
                       .load(new FileInputStream(Settings.getSettings().getConfigFile()));
                   tabbedPane.remove(1);
                   optionsPane = new OptionsPane(Settings.getSettings());
                   tabbedPane.add(optionsPane, 1);
                   tabbedPane.setIconAt(
                       1, new ImageIcon(this.getClass().getResource("/image/tabs/options.png")));
                 } catch (Exception e1) {
                   Logger.logError("Failed to reload settings after launcher closed", e1);
                 }
               }
             }
           });
     }
   } catch (Exception e) {
   }
 }
Example #13
0
 private static int getIndex() {
   if (currentPacks.size() > 0) {
     if (currentPacks.size() != ModPack.getPackArray().size()) {
       if (!origin.equalsIgnoreCase("all")) {
         return currentPacks.get(selectedPack).getIndex();
       }
     }
   }
   return selectedPack;
 }
Example #14
0
 public static void searchPacks(String search) {
   System.out.println("Searching Packs for : " + search);
   packPanels.clear();
   packs.removeAll();
   currentPacks.clear();
   packs.setMinimumSize(new Dimension(420, 0));
   packs.setPreferredSize(new Dimension(420, 0));
   packs.setLayout(null);
   packs.setOpaque(false);
   int counter = 0;
   selectedPack = 0;
   for (ModPack pack : ModPack.getPackArray()) {
     if (pack.getName().equalsIgnoreCase(search) || pack.getAuthor().equalsIgnoreCase(search)) {
       addPack(pack);
       currentPacks.put(counter, pack);
       counter++;
     }
   }
   updatePacks();
 }
Example #15
0
 public static void clearModsFolder(ModPack pack) {
   File modsFolder =
       new File(
           Settings.getSettings().getInstallPath(),
           pack.getDir() + File.separator + "minecraft" + File.separator + "mods");
   clearFolder(modsFolder);
   Logger.logInfo("Mods Folder: " + modsFolder.toString());
   File dyn = new File(baseDynamic.getPath(), "minecraft" + File.separator + "mods");
   Logger.logInfo("Dynamic Folder: " + dyn);
   clearFolder(dyn);
 }
Example #16
0
 private static void updatePacks() {
   for (int i = 0; i < packPanels.size(); i++) {
     if (selectedPack == i) {
       String mods = "";
       if (ModPack.getPack(getIndex()).getMods() != null) {
         mods += "<p>This pack contains the following mods by default:</p><ul>";
         for (String name : ModPack.getPack(getIndex()).getMods()) {
           mods += "<li>" + name + "</li>";
         }
         mods += "</ul>";
       }
       packPanels.get(i).setBackground(UIManager.getColor("control").darker().darker());
       splash.setIcon(new ImageIcon(ModPack.getPack(getIndex()).getImage()));
       packPanels.get(i).setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
       packInfo.setText(ModPack.getPack(getIndex()).getInfo() + mods);
     } else {
       packPanels.get(i).setBackground(UIManager.getColor("control"));
       packPanels.get(i).setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
     }
   }
 }
 public static int getIndex() {
   if (currentPacks.size() > 0) {
     if (currentPacks.size() != ModPack.getPackArray().size()) {
       if (!origin.equalsIgnoreCase("all")
           || type.equalsIgnoreCase("server")
           || searched
           || !mcVersion.equalsIgnoreCase("all")) {
         return currentPacks.get(selectedPack).getIndex();
       }
     }
   }
   return selectedPack;
 }
Example #18
0
 /**
  * @param modPackName - The pack to install (should already be downloaded)
  * @throws IOException
  */
 protected void installMods(String modPackName) throws IOException {
   String installpath = Settings.getSettings().getInstallPath();
   String temppath = OSUtils.getDynamicStorageLocation();
   ModPack pack = ModPack.getPack(modPacksPane.getSelectedModIndex());
   Logger.logInfo("dirs mk'd");
   File source = new File(temppath, "ModPacks/" + pack.getDir() + "/.minecraft");
   if (!source.exists()) {
     source = new File(temppath, "ModPacks/" + pack.getDir() + "/minecraft");
   }
   FileUtils.copyFolder(source, new File(installpath, pack.getDir() + "/minecraft/"));
   FileUtils.copyFolder(
       new File(temppath, "ModPacks/" + pack.getDir() + "/instMods/"),
       new File(installpath, pack.getDir() + "/instMods/"));
 }
 public static void clearModsFolder(ModPack pack) {
   File modsFolder =
       new File(Settings.getSettings().getInstallPath(), pack.getDir() + "/minecraft/mods");
   if (modsFolder.exists()) {
     for (String file : modsFolder.list()) {
       if (file.toLowerCase().endsWith(".zip")
           || file.toLowerCase().endsWith(".jar")
           || file.toLowerCase().endsWith(".disabled")
           || file.toLowerCase().endsWith(".litemod")) {
         try {
           FileUtils.delete(new File(modsFolder, file));
         } catch (IOException e) {
           e.printStackTrace();
         }
       }
     }
   }
 }
 public static void cleanUp() {
   ModPack pack = ModPack.getSelectedPack();
   File tempFolder =
       new File(OSUtils.getDynamicStorageLocation(), "ModPacks" + sep + pack.getDir() + sep);
   for (String file : tempFolder.list()) {
     if (!file.equals(pack.getLogoName())
         && !file.equals(pack.getImageName())
         && !file.equals("version")
         && !file.equals(pack.getAnimation())) {
       try {
         if (Settings.getSettings().getDebugLauncher() && file.endsWith(".zip")) {
           Logger.logInfo("debug: retaining modpack file: " + tempFolder + File.separator + file);
         } else {
           FileUtils.delete(new File(tempFolder, file));
         }
       } catch (IOException e) {
         Logger.logError(e.getMessage(), e);
       }
     }
   }
 }
  /*
   * GUI Code to add a modpack to the selection
   */
  public void addPack(final ModPack pack) {
    if (!modPacksAdded) {
      modPacksAdded = true;
      packs.removeAll();
      packs.repaint();
    }
    final int packIndex = packPanels.size();
    final JPanel p = new JPanel();
    p.setBounds(0, (packIndex * 55), 420, 55);
    p.setLayout(null);
    JLabel logo = new JLabel(new ImageIcon(pack.getLogo()));
    logo.setBounds(6, 6, 42, 42);
    logo.setVisible(true);

    JTextArea filler =
        new JTextArea(
            pack.getName()
                + " (v"
                + pack.getVersion()
                + ") Minecraft Version "
                + pack.getMcVersion()
                + "\n"
                + "By "
                + pack.getAuthor());
    filler.setBorder(null);
    filler.setEditable(false);
    filler.setForeground(LauncherStyle.getCurrentStyle().tabPaneForeground);
    filler.setBounds(58, 6, 362, 42);
    filler.setBackground(LauncherStyle.getCurrentStyle().tabPaneBackground);

    MouseAdapter lin =
        new MouseAdapter() {
          @Override
          public void mouseClicked(MouseEvent e) {
            if (e.getClickCount() == 2) {
              LaunchFrame.getInstance().doLaunch();
            }
          }

          @Override
          public void mousePressed(MouseEvent e) {
            selectedPack = packIndex;
            updatePacks();
          }
        };
    p.addMouseListener(lin);
    filler.addMouseListener(lin);
    logo.addMouseListener(lin);
    p.add(filler);
    p.add(logo);
    packPanels.add(p);
    packs.add(p);

    packs.setMinimumSize(new Dimension(420, (packPanels.size() * 55)));
    packs.setPreferredSize(new Dimension(420, (packPanels.size() * 55)));

    //
    // packsScroll.revalidate();
    if (pack.getDir().equalsIgnoreCase(getLastPack())) {
      selectedPack = packIndex;
    }
  }
    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;
    }
  // WTF: this does not update packs!!
  // only updating info for selected pack. pulldown menus and info area!
  void updatePacks() {
    for (int i = 0; i < packPanels.size(); i++) {
      if (selectedPack == i && getIndex() >= 0) {
        ModPack pack = ModPack.getPackArray().get(getIndex());
        if (pack != null) {
          String mods = "";
          if (pack.getMods() != null) {
            mods += "<p>This pack contains the following mods by default:</p><ul>";
            for (String name : pack.getMods()) {
              mods += "<li>" + name + "</li>";
            }
            mods += "</ul>";
          }
          packPanels.get(i).setBackground(UIManager.getColor("control").darker().darker());
          packPanels.get(i).setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
          File tempDir =
              new File(
                  OSUtils.getCacheStorageLocation(), "ModPacks" + File.separator + pack.getDir());
          packInfo.setText(
              "<html><img src='file:///"
                  + tempDir.getPath()
                  + File.separator
                  + pack.getImageName()
                  + "' width=400 height=200></img> <br>"
                  + pack.getInfo()
                  + mods);
          packInfo.setCaretPosition(0);

          if (ModPack.getSelectedPack(isFTB()).getServerUrl().equals("")
              || ModPack.getSelectedPack(isFTB()).getServerUrl() == null) {
            server.setEnabled(false);
          } else {
            server.setEnabled(true);
          }
          String tempVer = Settings.getSettings().getPackVer(pack.getDir());
          version.removeActionListener(al);
          version.removeAllItems();
          version.addItem("Recommended");
          if (pack.getOldVersions() != null) {
            for (String s : pack.getOldVersions()) {
              version.addItem(s);
            }
            version.setSelectedItem(tempVer);
          }
          version.addActionListener(al);
        }
      } else {
        packPanels.get(i).setBackground(UIManager.getColor("control"));
        packPanels.get(i).setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
      }
    }
  }
 boolean mcVersionCheck(ModPack pack) {
   return (mcVersion.equalsIgnoreCase(I18N.getLocaleString("MAIN_ALL")))
       || (mcVersion.equalsIgnoreCase(pack.getMcVersion()));
 }
 boolean textSearch(ModPack pack) {
   String searchString = SearchDialog.lastPackSearch.toLowerCase();
   return ((searchString.isEmpty())
       || pack.getName().toLowerCase().contains(searchString)
       || pack.getAuthor().toLowerCase().contains(searchString));
 }
Example #26
0
  public MapFilterDialog(MapUtils instance) {
    super(LaunchFrame.getInstance(), true);
    this.pane = instance;

    setupGui();

    getRootPane().setDefaultButton(apply);

    this.pane = instance;

    type.setSelectedItem(pane.type);
    origin.setSelectedItem(pane.origin);
    compatiblePack.setSelectedItem(pane.compatible);

    ArrayList<String> packs = new ArrayList<String>();
    compatiblePack.addItem(I18N.getLocaleString("MAIN_ALL"));
    packs.add(I18N.getLocaleString("MAIN_ALL"));
    for (int i = 0; i < Map.getMapArray().size(); i++) {
      String[] compat = Map.getMap(i).getCompatible();
      for (String compatable : compat) {
        if (!compatable.isEmpty()
            && !packs.contains(ModPack.getPack(compatable.trim()).getName())) {
          packs.add(ModPack.getPack(compatable.trim()).getName());
          compatiblePack.addItem(ModPack.getPack(compatable.trim()).getName());
        }
      }
    }

    type.setModel(new DefaultComboBoxModel(new String[] {"Client", "Server"}));
    origin.setModel(
        new DefaultComboBoxModel(
            new String[] {
              I18N.getLocaleString("MAIN_ALL"), "FTB", I18N.getLocaleString("FILTER_3THPARTY")
            }));
    compatiblePack.setModel(new DefaultComboBoxModel(packs.toArray()));

    apply.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent arg0) {
            pane.compatible = (String) compatiblePack.getSelectedItem();
            pane.type = (String) type.getSelectedItem();
            pane.origin = (String) origin.getSelectedItem();
            pane.updateFilter();
            setVisible(false);
          }
        });

    cancel.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent e) {
            setVisible(false);
          }
        });

    search.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent arg0) {
            SearchDialog sd = new SearchDialog(pane);
            sd.setVisible(true);
            setVisible(false);
          }
        });
  }
Example #27
0
 public String getPackVer() {
   return getProperty(ModPack.getSelectedPack().getDir(), "Recommended Version");
 }
Example #28
0
  /**
   * checks whether an update is needed, and then starts the update process off
   *
   * @param response - the response from the minecraft servers
   */
  private void runGameUpdater(final LoginResponse response) {
    final String installPath = Settings.getSettings().getInstallPath();
    final ModPack pack = ModPack.getSelectedPack();
    if (Settings.getSettings().getForceUpdate()
        && new File(installPath, pack.getDir() + File.separator + "version").exists()) {
      new File(installPath, pack.getDir() + File.separator + "version").delete();
    }
    if (!initializeMods()) {
      enableObjects();
      return;
    }
    try {
      TextureManager.updateTextures();
    } catch (Exception e1) {
    }
    MinecraftVersionDetector mvd = new MinecraftVersionDetector();
    if (!new File(installPath, pack.getDir() + "/minecraft/bin/minecraft.jar").exists()
        || mvd.shouldUpdate(installPath + "/" + pack.getDir() + "/minecraft")) {
      final ProgressMonitor progMonitor =
          new ProgressMonitor(this, "Downloading minecraft...", "", 0, 100);
      final GameUpdateWorker updater =
          new GameUpdateWorker(
              pack.getMcVersion(),
              new File(installPath, pack.getDir() + "/minecraft/bin").getPath()) {
            @Override
            public void done() {
              progMonitor.close();
              try {
                if (get()) {
                  Logger.logInfo("Game update complete");
                  FileUtils.killMetaInf();
                  launchMinecraft(
                      installPath + "/" + pack.getDir() + "/minecraft",
                      RESPONSE.getUsername(),
                      RESPONSE.getSessionID());
                } else {
                  ErrorUtils.tossError("Error occurred during downloading the game");
                }
              } catch (CancellationException e) {
                ErrorUtils.tossError("Game update canceled.");
              } catch (InterruptedException e) {
                ErrorUtils.tossError("Game update interrupted.");
              } catch (ExecutionException e) {
                ErrorUtils.tossError("Failed to download game.");
              } finally {
                enableObjects();
              }
            }
          };

      updater.addPropertyChangeListener(
          new PropertyChangeListener() {
            @Override
            public void propertyChange(PropertyChangeEvent evt) {
              if (progMonitor.isCanceled()) {
                updater.cancel(false);
              }
              if (!updater.isDone()) {
                int prog = updater.getProgress();
                if (prog < 0) {
                  prog = 0;
                } else if (prog > 100) {
                  prog = 100;
                }
                progMonitor.setProgress(prog);
                progMonitor.setNote(updater.getStatus());
              }
            }
          });
      updater.execute();
    } else {
      launchMinecraft(
          installPath + "/" + pack.getDir() + "/minecraft",
          RESPONSE.getUsername(),
          RESPONSE.getSessionID());
    }
  }
  public ModPackFilterDialog(ModpacksPane instance) {
    super(LaunchFrame.getInstance(), true);
    this.pane = instance;

    setupGui();

    getRootPane().setDefaultButton(apply);

    this.pane = instance;

    ArrayList<String> mcVersions = new ArrayList<String>();
    mcVersion.addItem("All");
    mcVersions.add("All");
    for (ModPack pack : ModPack.getPackArray()) {
      if (!mcVersions.contains(pack.getMcVersion())) {
        mcVersions.add(pack.getMcVersion());
        mcVersion.addItem(pack.getMcVersion());
      }
    }

    mcVersion.setModel(new DefaultComboBoxModel(mcVersions.toArray()));
    origin.setModel(
        new DefaultComboBoxModel(
            new String[] {
              I18N.getLocaleString("MAIN_ALL"), "FTB", I18N.getLocaleString("FILTER_3THPARTY")
            }));
    availability.setModel(
        new DefaultComboBoxModel(
            new String[] {
              I18N.getLocaleString("MAIN_ALL"),
              I18N.getLocaleString("FILTER_PUBLIC"),
              I18N.getLocaleString("FILTER_PRIVATE")
            }));

    origin.setSelectedItem(pane.origin);
    mcVersion.setSelectedItem(pane.mcVersion);
    availability.setSelectedItem(pane.avaliability);

    pack();

    apply.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent arg0) {
            pane.origin = (String) origin.getSelectedItem();
            pane.mcVersion = (String) mcVersion.getSelectedItem();
            pane.avaliability = (String) availability.getSelectedItem();
            pane.updateFilter();
            setVisible(false);
          }
        });

    cancel.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent e) {
            setVisible(false);
          }
        });

    search.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent arg0) {
            SearchDialog sd = new SearchDialog(pane);
            sd.setVisible(true);
            setVisible(false);
          }
        });
  }
Example #30
0
 public String getLastThirdPartyPack() {
   return getProperty("lastThirdPartyPack", ModPack.getPack(0).getDir());
 }