Beispiel #1
0
 /** updates the buttons/text to language specific */
 public void updateLocale() {
   if (I18N.currentLocale == Locale.deDE) {
     edit.setBounds(420, 20, 120, 30);
     donate.setBounds(330, 20, 80, 30);
     mapInstall.setBounds(620, 20, 190, 30);
     mapInstallLocation.setBounds(420, 20, 190, 30);
     serverbutton.setBounds(420, 20, 390, 30);
     tpInstallLocation.setBounds(420, 20, 190, 30);
     tpInstall.setBounds(620, 20, 190, 30);
   } else {
     edit.setBounds(480, 20, 60, 30);
     donate.setBounds(390, 20, 80, 30);
     mapInstall.setBounds(650, 20, 160, 30);
     mapInstallLocation.setBounds(480, 20, 160, 30);
     serverbutton.setBounds(480, 20, 330, 30);
     tpInstallLocation.setBounds(480, 20, 160, 30);
     tpInstall.setBounds(650, 20, 160, 30);
   }
   launch.setText(I18N.getLocaleString("LAUNCH_BUTTON"));
   edit.setText(I18N.getLocaleString("EDIT_BUTTON"));
   serverbutton.setText(I18N.getLocaleString("DOWNLOAD_SERVER_PACK"));
   mapInstall.setText(I18N.getLocaleString("INSTALL_MAP"));
   serverMap.setText(I18N.getLocaleString("DOWNLOAD_MAP_SERVER"));
   tpInstall.setText(I18N.getLocaleString("INSTALL_TEXTUREPACK"));
   donate.setText(I18N.getLocaleString("DONATE_BUTTON"));
   dropdown_[0] = I18N.getLocaleString("PROFILE_SELECT");
   dropdown_[1] = I18N.getLocaleString("PROFILE_CREATE");
   writeUsers((String) users.getSelectedItem());
   optionsPane.updateLocale();
   modPacksPane.updateLocale();
   mapsPane.updateLocale();
   tpPane.updateLocale();
 }
Beispiel #2
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/"));
 }
Beispiel #3
0
 /**
  * Used to grab the currently selected ModPack based off the selected index from ModPacksPane
  *
  * @return ModPack - the currently selected ModPack
  */
 public static ModPack getSelectedPack() {
   return getPack(ModpacksPane.getIndex());
 }
  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();
  }