Пример #1
0
  /**
   * Creates new form InstallerPanel
   *
   * @param gsp To get the minecraft version
   * @param installerType load which installer
   */
  public InstallerPanel(GameSettingsPanel gsp, InstallerType installerType) {
    initComponents();

    setOpaque(false);
    this.gsp = gsp;
    id = installerType;
    list = Settings.getInstance().getDownloadSource().getProvider().getInstallerByType(id);
  }
Пример #2
0
  @SuppressWarnings({"CallToPrintStackTrace", "UseSpecificCatch"})
  public static void main(String[] args) throws IOException {
    {
      PluginManager.getPlugin(DefaultPlugin.class);
      if (IUpgrader.NOW_UPGRADER.parseArguments(getVersionNumber(), args)) return;

      System.setProperty("awt.useSystemAAFontSettings", "on");
      System.setProperty("swing.aatext", "true");
      System.setProperty("sun.java2d.noddraw", "true");
      System.setProperty("sun.java2d.dpiaware", "false");
      Thread.setDefaultUncaughtExceptionHandler(new CrashReporter(true));

      try {
        File file = new File("hmcl.log");
        if (!file.exists() && !file.createNewFile())
          HMCLog.warn("Failed to create log file " + file);
        Configuration.DEFAULT.appenders.add(
            new ConsoleAppender(
                "File", new DefaultLayout(), true, new FileOutputStream(file), true));
      } catch (IOException ex) {
        LOGGER.log(
            Level.SEVERE,
            "Failed to add log appender File because an error occurred while creating or opening hmcl.log",
            ex);
      }

      HMCLog.log("*** " + Main.makeTitle() + " ***");

      String s = Settings.getInstance().getLocalization();
      for (SupportedLocales sl : SupportedLocales.values())
        if (sl.name().equals(s)) {
          SupportedLocales.NOW_LOCALE = sl;
          Locale.setDefault(sl.self);
        }

      LogWindow.INSTANCE.clean();
      LogWindow.INSTANCE.setTerminateGame(GameLauncher.PROCESS_MANAGER::stopAllProcesses);

      try {
        LOOK_AND_FEEL = new HelloMinecraftLookAndFeel(Settings.getInstance().getTheme().settings);
        UIManager.setLookAndFeel(LOOK_AND_FEEL);
      } catch (ParseException | UnsupportedLookAndFeelException ex) {
        HMCLog.warn("Failed to set look and feel...", ex);
      }

      Settings.UPDATE_CHECKER.outdated.register(IUpgrader.NOW_UPGRADER);
      Settings.UPDATE_CHECKER.process(false).reg(t -> Main.invokeUpdate()).execute();

      if (StrUtils.isNotBlank(Settings.getInstance().getProxyHost())
          && StrUtils.isNotBlank(Settings.getInstance().getProxyPort())
          && MathUtils.canParseInt(Settings.getInstance().getProxyPort())) {
        HMCLog.log("Initializing customized proxy");
        System.setProperty("http.proxyHost", Settings.getInstance().getProxyHost());
        System.setProperty("http.proxyPort", Settings.getInstance().getProxyPort());
        if (StrUtils.isNotBlank(Settings.getInstance().getProxyUserName())
            && StrUtils.isNotBlank(Settings.getInstance().getProxyPassword()))
          Authenticator.setDefault(
              new Authenticator() {
                @Override
                protected PasswordAuthentication getPasswordAuthentication() {
                  return new PasswordAuthentication(
                      Settings.getInstance().getProxyUserName(),
                      Settings.getInstance().getProxyPassword().toCharArray());
                }
              });
      }

      try {
        PluginManager.plugin().showUI();
      } catch (Throwable t) {
        new CrashReporter(false).uncaughtException(Thread.currentThread(), t);
        System.exit(1);
      }
    }
  }