Search in sources :

Example 1 with HttpUpdateStream

use of net.technicpack.autoupdate.http.HttpUpdateStream in project LauncherV3 by TechnicPack.

the class LauncherMain method main.

public static void main(String[] argv) {
    try {
        UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
    } catch (Exception ex) {
        Utils.getLogger().log(Level.SEVERE, ex.getMessage(), ex);
    }
    ToolTipManager.sharedInstance().setDismissDelay(Integer.MAX_VALUE);
    StartupParameters params = new StartupParameters(argv);
    try {
        JCommander.newBuilder().addObject(params).build().parse(argv);
    } catch (Exception ex) {
        ex.printStackTrace();
    }
    TechnicSettings settings = null;
    try {
        settings = SettingsFactory.buildSettingsObject(Relauncher.getRunningPath(LauncherMain.class), params.isMover());
    } catch (UnsupportedEncodingException ex) {
        ex.printStackTrace();
    }
    if (settings == null) {
        ResourceLoader installerResources = new ResourceLoader(null, "net", "technicpack", "launcher", "resources");
        installerResources.setSupportedLanguages(supportedLanguages);
        installerResources.setLocale(ResourceLoader.DEFAULT_LOCALE);
        InstallerFrame dialog = new InstallerFrame(installerResources, params);
        dialog.setVisible(true);
        return;
    }
    LauncherDirectories directories = new TechnicLauncherDirectories(settings.getTechnicRoot());
    ResourceLoader resources = new ResourceLoader(directories, "net", "technicpack", "launcher", "resources");
    resources.setSupportedLanguages(supportedLanguages);
    resources.setLocale(settings.getLanguageCode());
    // Sanity check
    checkIfRunningInsideOneDrive(directories.getLauncherDirectory());
    if (params.getBuildNumber() != null && !params.getBuildNumber().isEmpty())
        buildNumber = new CommandLineBuildNumber(params);
    else
        buildNumber = new VersionFileBuildNumber(resources);
    TechnicConstants.setBuildNumber(buildNumber);
    setupLogging(directories, resources);
    String launcherBuild = buildNumber.getBuildNumber();
    int build = -1;
    try {
        build = Integer.parseInt((new VersionFileBuildNumber(resources)).getBuildNumber());
    } catch (NumberFormatException ex) {
    // This is probably a debug build or something, build number is invalid
    }
    // These 2 need to happen *before* the launcher or the updater run so we have valuable debug information and so
    // we can properly use websites that use Let's Encrypt (and other current certs not supported by old Java versions)
    runStartupDebug();
    injectNewRootCerts();
    Relauncher launcher = new TechnicRelauncher(new HttpUpdateStream("https://api.technicpack.net/launcher/"), settings.getBuildStream() + "4", build, directories, resources, params);
    try {
        if (launcher.runAutoUpdater())
            startLauncher(settings, params, directories, resources);
    } catch (InterruptedException e) {
    // Canceled by user
    } catch (DownloadException e) {
    // JOptionPane.showMessageDialog(null, resources.getString("launcher.updateerror.download", pack.getDisplayName(), e.getMessage()), resources.getString("launcher.installerror.title"), JOptionPane.WARNING_MESSAGE);
    } catch (IOException e) {
        e.printStackTrace();
    }
}
Also used : VersionFileBuildNumber(net.technicpack.launcher.autoupdate.VersionFileBuildNumber) ResourceLoader(net.technicpack.ui.lang.ResourceLoader) LauncherDirectories(net.technicpack.launchercore.install.LauncherDirectories) ResetJvmArgsIfDefaultString(net.technicpack.launcher.settings.migration.ResetJvmArgsIfDefaultString) KeyStoreException(java.security.KeyStoreException) KeyManagementException(java.security.KeyManagementException) NoSuchAlgorithmException(java.security.NoSuchAlgorithmException) DownloadException(net.technicpack.launchercore.exception.DownloadException) CertificateException(java.security.cert.CertificateException) UnknownHostException(java.net.UnknownHostException) HttpUpdateStream(net.technicpack.autoupdate.http.HttpUpdateStream) Relauncher(net.technicpack.autoupdate.Relauncher) TechnicRelauncher(net.technicpack.launcher.autoupdate.TechnicRelauncher) DownloadException(net.technicpack.launchercore.exception.DownloadException) TechnicRelauncher(net.technicpack.launcher.autoupdate.TechnicRelauncher) TechnicSettings(net.technicpack.launcher.settings.TechnicSettings) InstallerFrame(net.technicpack.launcher.ui.InstallerFrame) StartupParameters(net.technicpack.launcher.settings.StartupParameters) CommandLineBuildNumber(net.technicpack.launcher.autoupdate.CommandLineBuildNumber)

Aggregations

UnknownHostException (java.net.UnknownHostException)1 KeyManagementException (java.security.KeyManagementException)1 KeyStoreException (java.security.KeyStoreException)1 NoSuchAlgorithmException (java.security.NoSuchAlgorithmException)1 CertificateException (java.security.cert.CertificateException)1 Relauncher (net.technicpack.autoupdate.Relauncher)1 HttpUpdateStream (net.technicpack.autoupdate.http.HttpUpdateStream)1 CommandLineBuildNumber (net.technicpack.launcher.autoupdate.CommandLineBuildNumber)1 TechnicRelauncher (net.technicpack.launcher.autoupdate.TechnicRelauncher)1 VersionFileBuildNumber (net.technicpack.launcher.autoupdate.VersionFileBuildNumber)1 StartupParameters (net.technicpack.launcher.settings.StartupParameters)1 TechnicSettings (net.technicpack.launcher.settings.TechnicSettings)1 ResetJvmArgsIfDefaultString (net.technicpack.launcher.settings.migration.ResetJvmArgsIfDefaultString)1 InstallerFrame (net.technicpack.launcher.ui.InstallerFrame)1 DownloadException (net.technicpack.launchercore.exception.DownloadException)1 LauncherDirectories (net.technicpack.launchercore.install.LauncherDirectories)1 ResourceLoader (net.technicpack.ui.lang.ResourceLoader)1