Esempio n. 1
0
 /**
  * updates the mapInstall to the available ones
  *
  * @param locations - the available locations to install the map to
  */
 public static void updateMapInstallLocs(String[] locations) {
   mapInstallLocation.removeAllItems();
   for (String location : locations) {
     if (!location.isEmpty()) {
       mapInstallLocation.addItem(ModPack.getPack(location.trim()).getName());
     }
   }
 }
Esempio n. 2
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));
     }
   }
 }
Esempio n. 3
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/"));
 }
Esempio n. 4
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);
          }
        });
  }
Esempio n. 5
0
 public String getLastThirdPartyPack() {
   return getProperty("lastThirdPartyPack", ModPack.getPack(0).getDir());
 }
Esempio n. 6
0
  public static Process launchMinecraft(
      String workingDir,
      String username,
      String password,
      String forgename,
      String rmax,
      String addOpt)
      throws IOException {
    String[] jarFiles = new String[] {"minecraft.jar", "lwjgl.jar", "lwjgl_util.jar", "jinput.jar"};
    StringBuilder cpb = new StringBuilder("");
    File tempDir = new File(new File(workingDir).getParentFile(), "/instMods/");
    if (tempDir.isDirectory()) {
      for (String name : tempDir.list()) {
        if (name.toLowerCase().contains("forge") && name.toLowerCase().endsWith(".zip")) {
          if (!name.toLowerCase().equalsIgnoreCase(forgename)) {
            if (new File(tempDir, forgename).exists()) {
              new File(tempDir, name).delete();
            } else {
              new File(tempDir, name).renameTo(new File(tempDir, forgename));
            }
          }
        }
        if (!name.equalsIgnoreCase(forgename)) {
          if (name.toLowerCase().endsWith(".zip") || name.toLowerCase().endsWith(".jar")) {
            cpb.append(OSUtils.getJavaDelimiter());
            cpb.append(new File(tempDir, name).getAbsolutePath());
          }
        }
      }
    } else {
      Logger.logInfo("Not a directory.");
    }

    cpb.append(OSUtils.getJavaDelimiter());
    cpb.append(new File(tempDir, forgename).getAbsolutePath());

    for (String jarFile : jarFiles) {
      cpb.append(OSUtils.getJavaDelimiter());
      cpb.append(new File(new File(workingDir, "bin"), jarFile).getAbsolutePath());
    }

    List<String> arguments = new ArrayList<String>();

    String separator = System.getProperty("file.separator");
    String path = System.getProperty("java.home") + separator + "bin" + separator + "java";
    arguments.add(path);

    setMemory(arguments, rmax);

    // If given, add additional command line options (e.g. -Djava.net.preferIPv4Stack=true)
    arguments.add(addOpt);

    arguments.add("-cp");
    arguments.add(System.getProperty("java.class.path") + cpb.toString());

    arguments.add(MinecraftLauncher.class.getCanonicalName());
    arguments.add(workingDir);
    arguments.add(forgename);
    arguments.add(username);
    arguments.add(password);
    arguments.add(ModPack.getPack(ModpacksPane.getIndex()).getName());
    arguments.add(
        OSUtils.getDynamicStorageLocation()
            + "ModPacks"
            + separator
            + ModPack.getPack(ModpacksPane.getIndex()).getDir()
            + separator
            + ModPack.getPack(ModpacksPane.getIndex()).getLogoName());
    arguments.add(Settings.getSettings().getMinecraftX());
    arguments.add(Settings.getSettings().getMinecraftY());
    arguments.add(Settings.getSettings().getMinecraftXPos());
    arguments.add(Settings.getSettings().getMinecraftYPos());
    arguments.add(Settings.getSettings().getAutoMaximize());
    arguments.add(Settings.getSettings().getCenterWindow());

    ProcessBuilder processBuilder = new ProcessBuilder(arguments);
    processBuilder.redirectErrorStream(true);
    return processBuilder.start();
  }