Add --proxy

This commit is contained in:
huanghongxun
2015-12-10 20:34:02 +08:00
parent e91d4c5477
commit 78c46aeb64
16 changed files with 144 additions and 128 deletions

View File

@@ -1,18 +1,19 @@
/* /*
* Copyright 2013 huangyuhui <huanghongxun2008@126.com> * Hello Minecraft! Launcher.
* Copyright (C) 2013 huangyuhui <huanghongxun2008@126.com>
* *
* This program is free software; you can redistribute it and/or modify * This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or * the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version. * (at your option) any later version.
* *
* This program is distributed in the hope that it will be useful, * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program. * along with this program. If not, see {http://www.gnu.org/licenses/}.
*/ */
import java.util.jar.JarOutputStream import java.util.jar.JarOutputStream
import java.util.zip.ZipEntry import java.util.zip.ZipEntry
@@ -25,7 +26,7 @@ if (!hasProperty('mainClass')) {
ext.mainClass = 'org.jackhuang.hellominecraft.launcher.Main' ext.mainClass = 'org.jackhuang.hellominecraft.launcher.Main'
} }
def buildnumber = System.getenv("BUILD_NUMBER") == null ? ".5" : "."+System.getenv("BUILD_NUMBER") def buildnumber = System.getenv("BUILD_NUMBER") == null ? ".6" : "."+System.getenv("BUILD_NUMBER")
String mavenGroupId = 'HMCL' String mavenGroupId = 'HMCL'
String mavenVersion = '2.3.5' + buildnumber String mavenVersion = '2.3.5' + buildnumber
@@ -73,7 +74,7 @@ jar {
from { configurations.compile.collect { it.isDirectory() ? it : zipTree(it) } } from { configurations.compile.collect { it.isDirectory() ? it : zipTree(it) } }
manifest { manifest {
attributes 'Created-By' : 'Copyright(c) 2013-2014 huangyuhui.', attributes 'Created-By' : 'Copyright(c) 2013-2016 huangyuhui.',
'Main-Class' : mainClass 'Main-Class' : mainClass
} }
} }
@@ -100,4 +101,4 @@ processResources {
} }
} }
build.dependsOn makeExecutable build.dependsOn makeExecutable

View File

@@ -20,16 +20,20 @@ package org.jackhuang.hellominecraft.launcher;
import java.io.File; import java.io.File;
import java.io.FileOutputStream; import java.io.FileOutputStream;
import java.lang.reflect.Method; import java.lang.reflect.Method;
import java.net.Authenticator;
import java.net.PasswordAuthentication;
import java.net.URL; import java.net.URL;
import java.net.URLClassLoader; import java.net.URLClassLoader;
import java.util.ArrayList; import java.util.ArrayList;
import javax.swing.SwingUtilities; import javax.swing.SwingUtilities;
import org.jackhuang.hellominecraft.C; import org.jackhuang.hellominecraft.C;
import org.jackhuang.hellominecraft.HMCLog;
import org.jackhuang.hellominecraft.utils.StrUtils; import org.jackhuang.hellominecraft.utils.StrUtils;
import org.jackhuang.hellominecraft.views.LogWindow; import org.jackhuang.hellominecraft.views.LogWindow;
import org.jackhuang.hellominecraft.launcher.launch.MinecraftCrashAdvicer; import org.jackhuang.hellominecraft.launcher.launch.MinecraftCrashAdvicer;
import org.jackhuang.hellominecraft.utils.DoubleOutputStream; import org.jackhuang.hellominecraft.utils.DoubleOutputStream;
import org.jackhuang.hellominecraft.utils.LauncherPrintStream; import org.jackhuang.hellominecraft.utils.LauncherPrintStream;
import org.jackhuang.hellominecraft.utils.MathUtils;
import org.jackhuang.hellominecraft.utils.MessageBox; import org.jackhuang.hellominecraft.utils.MessageBox;
import org.jackhuang.hellominecraft.utils.Utils; import org.jackhuang.hellominecraft.utils.Utils;
@@ -42,12 +46,13 @@ public final class Launcher {
public static void println(String s) { public static void println(String s) {
System.out.println(s); System.out.println(s);
} }
static String classPath = "", proxyHost = "", proxyPort = "", proxyUsername = "", proxyPassword = "";
public static void main(String[] args) { public static void main(String[] args) {
println("*** " + Main.makeTitle() + " ***"); println("*** " + Main.makeTitle() + " ***");
boolean showInfo = false; boolean showInfo = false;
String classPath = "";
String mainClass = "net.minecraft.client.Minecraft"; String mainClass = "net.minecraft.client.Minecraft";
ArrayList<String> cmdList = new ArrayList<>(); ArrayList<String> cmdList = new ArrayList<>();
@@ -57,6 +62,14 @@ public final class Launcher {
classPath = classPath.concat(s.substring("-cp=".length())); classPath = classPath.concat(s.substring("-cp=".length()));
else if (s.startsWith("-mainClass=")) else if (s.startsWith("-mainClass="))
mainClass = s.substring("-mainClass=".length()); mainClass = s.substring("-mainClass=".length());
else if (s.startsWith("-proxyHost="))
proxyHost = s.substring("-proxyHost=".length());
else if (s.startsWith("-proxyPort="))
proxyPort = s.substring("-proxyPort=".length());
else if (s.startsWith("-proxyUsername="))
proxyUsername = s.substring("-proxyUsername=".length());
else if (s.startsWith("-proxyPassword="))
proxyPassword = s.substring("-proxyPassword=".length());
else if (s.equals("-debug")) else if (s.equals("-debug"))
showInfo = true; showInfo = true;
else else
@@ -87,6 +100,22 @@ public final class Launcher {
SwingUtilities.invokeLater(() -> LogWindow.INSTANCE.setVisible(true)); SwingUtilities.invokeLater(() -> LogWindow.INSTANCE.setVisible(true));
} }
if (StrUtils.isNotBlank(proxyHost) && StrUtils.isNotBlank(proxyPort) && MathUtils.canParseInt(proxyPort)) {
HMCLog.log("Initializing customized proxy");
System.setProperty("http.proxyHost", proxyHost);
System.setProperty("http.proxyPort", proxyPort);
if (StrUtils.isNotBlank(proxyUsername) && StrUtils.isNotBlank(proxyPassword))
Authenticator.setDefault(new Authenticator() {
@Override
protected PasswordAuthentication getPasswordAuthentication() {
return new PasswordAuthentication(proxyUsername, proxyPassword.toCharArray());
}
});
//PROXY = new Proxy(Proxy.Type.HTTP, new InetSocketAddress(Settings.getInstance().getProxyHost(), Integer.parseInt(Settings.getInstance().getProxyPort())));
} else {
//PROXY = Proxy.NO_PROXY;
}
URL[] urls = new URL[len]; URL[] urls = new URL[len];
try { try {

View File

@@ -173,6 +173,15 @@ public abstract class AbstractMinecraftLoader implements IMinecraftLoader {
if (v.isDebug() && !v.isCanceledWrapper()) if (v.isDebug() && !v.isCanceledWrapper())
res.add("-debug"); res.add("-debug");
if (StrUtils.isNotBlank(Settings.getInstance().getProxyHost()) && StrUtils.isNotBlank(Settings.getInstance().getProxyPort()) && MathUtils.canParseInt(Settings.getInstance().getProxyPort())) {
res.add("-proxyHost=" + Settings.getInstance().getProxyHost());
res.add("-proxyPort=" + Settings.getInstance().getProxyPort());
if (StrUtils.isNotBlank(Settings.getInstance().getProxyUserName()) && StrUtils.isNotBlank(Settings.getInstance().getProxyPassword())) {
res.add("-proxyUsername=" + Settings.getInstance().getProxyUserName());
res.add("-proxyPassword=" + Settings.getInstance().getProxyPassword());
}
}
if (StrUtils.isNotBlank(v.getMinecraftArgs())) if (StrUtils.isNotBlank(v.getMinecraftArgs()))
res.addAll(Arrays.asList(v.getMinecraftArgs().split(" "))); res.addAll(Arrays.asList(v.getMinecraftArgs().split(" ")));

View File

@@ -22,7 +22,6 @@ import java.io.File;
import java.io.IOException; import java.io.IOException;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import javax.swing.SwingUtilities;
import org.jackhuang.hellominecraft.C; import org.jackhuang.hellominecraft.C;
import org.jackhuang.hellominecraft.HMCLog; import org.jackhuang.hellominecraft.HMCLog;
import org.jackhuang.hellominecraft.launcher.utils.auth.UserProfileProvider; import org.jackhuang.hellominecraft.launcher.utils.auth.UserProfileProvider;

View File

@@ -120,8 +120,9 @@ public final class Config {
} }
public TreeMap<String, Profile> getConfigurations() { public TreeMap<String, Profile> getConfigurations() {
if (configurations == null) { if (configurations == null)
configurations = new TreeMap<>(); configurations = new TreeMap<>();
if (configurations.isEmpty()) {
Profile profile = new Profile(); Profile profile = new Profile();
configurations.put(profile.getName(), profile); configurations.put(profile.getName(), profile);
} }

View File

@@ -72,9 +72,9 @@ public abstract class IAuthenticator {
/** /**
* Has password? * Has password?
* *
* @return Will I hide password box? * @return Need to hide password box?
*/ */
public boolean isHidePasswordBox() { public boolean hasPassword() {
return false; return false;
} }

View File

@@ -55,7 +55,7 @@ public final class OfflineAuthenticator extends IAuthenticator {
} }
@Override @Override
public boolean isHidePasswordBox() { public boolean hasPassword() {
return true; return true;
} }

View File

@@ -105,16 +105,15 @@ public final class GameSettingsPanel extends javax.swing.JPanel implements DropT
ppmExplore = new JPopupMenu(); ppmExplore = new JPopupMenu();
class ImplementedActionListener implements ActionListener { class ImplementedActionListener implements ActionListener {
String a;
ImplementedActionListener(String s) { ImplementedActionListener(String s) {
a = s; a = s;
} }
String a;
@Override @Override
public void actionPerformed(ActionEvent e) { public void actionPerformed(ActionEvent e) {
Profile v = getProfile(); getProfile().getMinecraftProvider().open(mcVersion, a);
if (v != null)
v.getMinecraftProvider().open(mcVersion, a);
} }
} }
JMenuItem itm; JMenuItem itm;
@@ -142,35 +141,31 @@ public final class GameSettingsPanel extends javax.swing.JPanel implements DropT
ppmManage = new JPopupMenu(); ppmManage = new JPopupMenu();
JMenuItem itm = new JMenuItem(C.i18n("versions.manage.rename")); JMenuItem itm = new JMenuItem(C.i18n("versions.manage.rename"));
itm.addActionListener((e) -> { itm.addActionListener((e) -> {
Profile v = getProfile(); if (mcVersion != null) {
if (v != null && mcVersion != null) {
String newName = JOptionPane.showInputDialog(C.i18n("versions.manage.rename.message"), mcVersion); String newName = JOptionPane.showInputDialog(C.i18n("versions.manage.rename.message"), mcVersion);
if (newName != null) if (newName != null)
if (v.getMinecraftProvider().renameVersion(mcVersion, newName)) if (getProfile().getMinecraftProvider().renameVersion(mcVersion, newName))
refreshVersions(); refreshVersions();
} }
}); });
ppmManage.add(itm); ppmManage.add(itm);
itm = new JMenuItem(C.i18n("versions.manage.remove")); itm = new JMenuItem(C.i18n("versions.manage.remove"));
itm.addActionListener((e) -> { itm.addActionListener((e) -> {
Profile v = getProfile(); if (mcVersion != null && MessageBox.Show(C.i18n("versions.manage.remove.confirm") + mcVersion, MessageBox.YES_NO_OPTION) == MessageBox.YES_OPTION)
if (v != null && mcVersion != null && MessageBox.Show(C.i18n("versions.manage.remove.confirm") + mcVersion, MessageBox.YES_NO_OPTION) == MessageBox.YES_OPTION) if (getProfile().getMinecraftProvider().removeVersionFromDisk(mcVersion))
if (v.getMinecraftProvider().removeVersionFromDisk(mcVersion))
refreshVersions(); refreshVersions();
}); });
ppmManage.add(itm); ppmManage.add(itm);
itm = new JMenuItem(C.i18n("versions.manage.redownload_json")); itm = new JMenuItem(C.i18n("versions.manage.redownload_json"));
itm.addActionListener((e) -> { itm.addActionListener((e) -> {
Profile v = getProfile(); if (mcVersion != null)
if (v != null && mcVersion != null) getProfile().getMinecraftProvider().refreshJson(mcVersion);
v.getMinecraftProvider().refreshJson(mcVersion);
}); });
ppmManage.add(itm); ppmManage.add(itm);
itm = new JMenuItem(C.i18n("versions.manage.redownload_assets_index")); itm = new JMenuItem(C.i18n("versions.manage.redownload_assets_index"));
itm.addActionListener((e) -> { itm.addActionListener((e) -> {
Profile v = getProfile(); if (mcVersion != null)
if (v != null && mcVersion != null) getProfile().getMinecraftProvider().getAssetService().refreshAssetsIndex(mcVersion);
v.getMinecraftProvider().getAssetService().refreshAssetsIndex(mcVersion);
}); });
ppmManage.add(itm); ppmManage.add(itm);
} }
@@ -1126,19 +1121,18 @@ btnRefreshLiteLoader.addActionListener(new java.awt.event.ActionListener() {
}//GEN-LAST:event_btnNewProfileActionPerformed }//GEN-LAST:event_btnNewProfileActionPerformed
private void btnRemoveProfileActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnRemoveProfileActionPerformed private void btnRemoveProfileActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnRemoveProfileActionPerformed
if (getProfile() == null)
return;
if (MessageBox.Show(C.i18n("ui.message.sure_remove", getProfile().getName()), MessageBox.YES_NO_OPTION) == MessageBox.NO_OPTION) if (MessageBox.Show(C.i18n("ui.message.sure_remove", getProfile().getName()), MessageBox.YES_NO_OPTION) == MessageBox.NO_OPTION)
return; return;
String name = getProfile().getName();
if (Settings.delProfile(getProfile())) { if (Settings.delProfile(getProfile())) {
cboProfiles.removeItem(getProfile().getName()); cboProfiles.removeItem(name);
prepare(getProfile()); prepare(getProfile());
loadVersions(); loadVersions();
} }
}//GEN-LAST:event_btnRemoveProfileActionPerformed }//GEN-LAST:event_btnRemoveProfileActionPerformed
private void cboVersionsItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_cboVersionsItemStateChanged private void cboVersionsItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_cboVersionsItemStateChanged
if (isLoading || evt.getStateChange() != ItemEvent.SELECTED || cboVersions.getSelectedIndex() < 0 || StrUtils.isBlank((String) cboVersions.getSelectedItem()) || getProfile() == null) if (isLoading || evt.getStateChange() != ItemEvent.SELECTED || cboVersions.getSelectedIndex() < 0 || StrUtils.isBlank((String) cboVersions.getSelectedItem()))
return; return;
String mcv = (String) cboVersions.getSelectedItem(); String mcv = (String) cboVersions.getSelectedItem();
loadMinecraftVersion(mcv); loadMinecraftVersion(mcv);
@@ -1252,7 +1246,7 @@ btnRefreshLiteLoader.addActionListener(new java.awt.event.ActionListener() {
}//GEN-LAST:event_cboLauncherVisibilityFocusLost }//GEN-LAST:event_cboLauncherVisibilityFocusLost
private void btnDownloadAllAssetsActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnDownloadAllAssetsActionPerformed private void btnDownloadAllAssetsActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnDownloadAllAssetsActionPerformed
if (mcVersion != null && getProfile() != null) if (mcVersion != null)
getProfile().getMinecraftProvider().getAssetService().downloadAssets(mcVersion).run(); getProfile().getMinecraftProvider().getAssetService().downloadAssets(mcVersion).run();
}//GEN-LAST:event_btnDownloadAllAssetsActionPerformed }//GEN-LAST:event_btnDownloadAllAssetsActionPerformed
@@ -1277,8 +1271,6 @@ btnRefreshLiteLoader.addActionListener(new java.awt.event.ActionListener() {
}//GEN-LAST:event_txtWidthFocusLost }//GEN-LAST:event_txtWidthFocusLost
private void txtGameDirFocusLost(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_txtGameDirFocusLost private void txtGameDirFocusLost(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_txtGameDirFocusLost
if (getProfile() == null)
return;
getProfile().setGameDir(txtGameDir.getText()); getProfile().setGameDir(txtGameDir.getText());
loadVersions(); loadVersions();
}//GEN-LAST:event_txtGameDirFocusLost }//GEN-LAST:event_txtGameDirFocusLost
@@ -1307,7 +1299,7 @@ btnRefreshLiteLoader.addActionListener(new java.awt.event.ActionListener() {
}//GEN-LAST:event_btnChoosingJavaDirActionPerformed }//GEN-LAST:event_btnChoosingJavaDirActionPerformed
private void cboJavaItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_cboJavaItemStateChanged private void cboJavaItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_cboJavaItemStateChanged
if (isLoading || evt.getStateChange() != ItemEvent.SELECTED || cboJava.getSelectedIndex() < 0 || StrUtils.isBlank((String) cboJava.getSelectedItem()) || getProfile() == null) if (isLoading || evt.getStateChange() != ItemEvent.SELECTED || cboJava.getSelectedIndex() < 0 || StrUtils.isBlank((String) cboJava.getSelectedItem()))
return; return;
int idx = cboJava.getSelectedIndex(); int idx = cboJava.getSelectedIndex();
if (idx != -1) { if (idx != -1) {
@@ -1325,11 +1317,11 @@ btnRefreshLiteLoader.addActionListener(new java.awt.event.ActionListener() {
fc.setMultiSelectionEnabled(true); fc.setMultiSelectionEnabled(true);
if (fc.showOpenDialog(this) != JFileChooser.APPROVE_OPTION) if (fc.showOpenDialog(this) != JFileChooser.APPROVE_OPTION)
return; return;
boolean flag = false; boolean flag = true;
for (File f : fc.getSelectedFiles()) for (File f : fc.getSelectedFiles())
flag |= !getProfile().getMinecraftProvider().getModService().addMod(f); flag &= getProfile().getMinecraftProvider().getModService().addMod(f);
reloadMods(); reloadMods();
if (flag) if (!flag)
MessageBox.Show(C.I18N.getString("mods.failed")); MessageBox.Show(C.I18N.getString("mods.failed"));
}//GEN-LAST:event_btnAddModActionPerformed }//GEN-LAST:event_btnAddModActionPerformed
@@ -1384,20 +1376,13 @@ btnRefreshLiteLoader.addActionListener(new java.awt.event.ActionListener() {
private void loadProfiles() { private void loadProfiles() {
isLoading = true; isLoading = true;
cboProfiles.removeAllItems(); cboProfiles.removeAllItems();
Profile firstProfile = null, selectedProfile = null;
int index = 0, i = 0; int index = 0, i = 0;
for (Profile s : Settings.getProfilesFiltered()) { for (Profile s : Settings.getProfilesFiltered()) {
if (firstProfile == null)
firstProfile = s;
cboProfiles.addItem(s.getName()); cboProfiles.addItem(s.getName());
if (Settings.getInstance().getLast() != null && Settings.getInstance().getLast().equals(s.getName())) { if (Settings.getInstance().getLast() != null && Settings.getInstance().getLast().equals(s.getName()))
index = i; index = i;
selectedProfile = s;
}
i++; i++;
} }
if (selectedProfile == null)
selectedProfile = Settings.getOneProfile();
isLoading = false; isLoading = false;
if (index < cboProfiles.getItemCount()) { if (index < cboProfiles.getItemCount()) {
@@ -1408,10 +1393,7 @@ btnRefreshLiteLoader.addActionListener(new java.awt.event.ActionListener() {
} }
final Profile getProfile() { final Profile getProfile() {
if (cboProfiles.getSelectedIndex() >= 0) return Settings.getProfile((String) cboProfiles.getSelectedItem());
return Settings.getProfile(cboProfiles.getSelectedItem().toString());
else
return Settings.getProfile(null);
} }
void prepare(Profile profile) { void prepare(Profile profile) {
@@ -1444,8 +1426,6 @@ btnRefreshLiteLoader.addActionListener(new java.awt.event.ActionListener() {
} }
void loadVersions() { void loadVersions() {
if (getProfile() == null)
return;
isLoading = true; isLoading = true;
cboVersions.removeAllItems(); cboVersions.removeAllItems();
int index = 0, i = 0; int index = 0, i = 0;
@@ -1502,7 +1482,7 @@ btnRefreshLiteLoader.addActionListener(new java.awt.event.ActionListener() {
} }
void downloadMinecraft() { void downloadMinecraft() {
if (getProfile() == null || lstDownloads.getSelectedRow() < 0) { if (lstDownloads.getSelectedRow() < 0) {
MessageBox.Show(C.i18n("gamedownload.not_refreshed")); MessageBox.Show(C.i18n("gamedownload.not_refreshed"));
return; return;
} }
@@ -1586,18 +1566,12 @@ btnRefreshLiteLoader.addActionListener(new java.awt.event.ActionListener() {
private List<InstallerVersionList.InstallerVersion> loadVersions(InstallerVersionList list, JTable table) { private List<InstallerVersionList.InstallerVersion> loadVersions(InstallerVersionList list, JTable table) {
if (list == null) if (list == null)
return null; return null;
DefaultTableModel model = (DefaultTableModel) table.getModel(); DefaultTableModel model = SwingUtils.clearDefaultTable(table);
while (model.getRowCount() > 0)
model.removeRow(0);
String mcver = StrUtils.formatVersion(getMinecraftVersionFormatted()); String mcver = StrUtils.formatVersion(getMinecraftVersionFormatted());
List<InstallerVersionList.InstallerVersion> ver = list.getVersions(mcver); List<InstallerVersionList.InstallerVersion> ver = list.getVersions(mcver);
if (ver != null) { if (ver != null) {
for (InstallerVersionList.InstallerVersion v : ver) { for (InstallerVersionList.InstallerVersion v : ver)
Object a = v.selfVersion == null ? "null" : v.selfVersion; model.addRow(new Object[] {v.selfVersion == null ? "null" : v.selfVersion, v.mcVersion == null ? "null" : v.mcVersion});
Object b = v.mcVersion == null ? "null" : v.mcVersion;
Object[] row = new Object[] {a, b};
model.addRow(row);
}
table.updateUI(); table.updateUI();
} }
return ver; return ver;
@@ -1634,8 +1608,6 @@ btnRefreshLiteLoader.addActionListener(new java.awt.event.ActionListener() {
public void onSelected() { public void onSelected() {
loadProfiles(); loadProfiles();
if (getProfile() == null)
return;
if (getProfile().getMinecraftProvider().getVersionCount() <= 0) if (getProfile().getMinecraftProvider().getVersionCount() <= 0)
versionChanged(null); versionChanged(null);
else else

View File

@@ -28,6 +28,7 @@ import org.jackhuang.hellominecraft.launcher.settings.Settings;
import org.jackhuang.hellominecraft.launcher.utils.download.DownloadType; import org.jackhuang.hellominecraft.launcher.utils.download.DownloadType;
import org.jackhuang.hellominecraft.utils.system.IOUtils; import org.jackhuang.hellominecraft.utils.system.IOUtils;
import org.jackhuang.hellominecraft.utils.MessageBox; import org.jackhuang.hellominecraft.utils.MessageBox;
import rx.Observable;
/** /**
* *
@@ -41,10 +42,8 @@ public class LauncherSettingsPanel extends javax.swing.JPanel {
public LauncherSettingsPanel() { public LauncherSettingsPanel() {
initComponents(); initComponents();
String[] strings = new String[DownloadType.values().length]; Observable.from(DownloadType.values()).map(t -> t.getName()).toList()
for (int i = 0; i < strings.length; i++) .subscribe(t -> cboDownloadSource.setModel(new DefaultComboBoxModel(t.toArray(new String[0]))));
strings[i] = DownloadType.values()[i].getName();
cboDownloadSource.setModel(new DefaultComboBoxModel(strings));
txtBackgroundPath.setText(Settings.getInstance().getBgpath()); txtBackgroundPath.setText(Settings.getInstance().getBgpath());
txtProxyHost.setText(Settings.getInstance().getProxyHost()); txtProxyHost.setText(Settings.getInstance().getProxyHost());

View File

@@ -276,14 +276,14 @@ public class MainPagePanel extends javax.swing.JPanel {
}//GEN-LAST:event_txtPlayerNameFocusLost }//GEN-LAST:event_txtPlayerNameFocusLost
private void cboLoginModeItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_cboLoginModeItemStateChanged private void cboLoginModeItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_cboLoginModeItemStateChanged
if (preaparingAuth) if (preparingAuth)
return; return;
int index = cboLoginMode.getSelectedIndex(); int index = cboLoginMode.getSelectedIndex();
if (index < 0) if (index < 0)
return; return;
IAuthenticator l = IAuthenticator.LOGINS.get(index); IAuthenticator l = IAuthenticator.LOGINS.get(index);
if (l.isHidePasswordBox()) { if (l.hasPassword()) {
pnlPassword.setVisible(false); pnlPassword.setVisible(false);
lblUserName.setText(C.i18n("login.username")); lblUserName.setText(C.i18n("login.username"));
} else { } else {
@@ -327,7 +327,7 @@ public class MainPagePanel extends javax.swing.JPanel {
}//GEN-LAST:event_txtPasswordActionPerformed }//GEN-LAST:event_txtPasswordActionPerformed
private void btnLogoutActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnLogoutActionPerformed private void btnLogoutActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnLogoutActionPerformed
if (preaparingAuth) if (preparingAuth)
return; return;
int index = cboLoginMode.getSelectedIndex(); int index = cboLoginMode.getSelectedIndex();
@@ -345,7 +345,7 @@ public class MainPagePanel extends javax.swing.JPanel {
if (index < 0) if (index < 0)
return; return;
IAuthenticator l = IAuthenticator.LOGINS.get(index); IAuthenticator l = IAuthenticator.LOGINS.get(index);
if (l.isHidePasswordBox()) if (l.hasPassword())
btnRunActionPerformed(); btnRunActionPerformed();
else if (!l.isLoggedIn()) else if (!l.isLoggedIn())
txtPassword.requestFocus(); txtPassword.requestFocus();
@@ -385,7 +385,7 @@ public class MainPagePanel extends javax.swing.JPanel {
return; return;
} }
final IAuthenticator l = IAuthenticator.LOGINS.get(index); final IAuthenticator l = IAuthenticator.LOGINS.get(index);
final LoginInfo li = new LoginInfo(Settings.getInstance().getUsername(), l.isLoggedIn() || l.isHidePasswordBox() ? null : new String(txtPassword.getPassword())); final LoginInfo li = new LoginInfo(Settings.getInstance().getUsername(), l.isLoggedIn() || l.hasPassword() ? null : new String(txtPassword.getPassword()));
new Thread() { new Thread() {
@Override @Override
public void run() { public void run() {
@@ -411,7 +411,7 @@ public class MainPagePanel extends javax.swing.JPanel {
// <editor-fold defaultstate="collapsed" desc="Loads"> // <editor-fold defaultstate="collapsed" desc="Loads">
private void prepareAuths() { private void prepareAuths() {
preaparingAuth = true; preparingAuth = true;
cboLoginMode.removeAllItems(); cboLoginMode.removeAllItems();
for (IAuthenticator str : IAuthenticator.LOGINS) for (IAuthenticator str : IAuthenticator.LOGINS)
try { try {
@@ -421,7 +421,7 @@ public class MainPagePanel extends javax.swing.JPanel {
} }
int loginType = Settings.getInstance().getLoginType(); int loginType = Settings.getInstance().getLoginType();
if (0 <= loginType && loginType < cboLoginMode.getItemCount()) { if (0 <= loginType && loginType < cboLoginMode.getItemCount()) {
preaparingAuth = false; preparingAuth = false;
//cboLoginMode.setSelectedIndex(loginType); //cboLoginMode.setSelectedIndex(loginType);
@@ -486,7 +486,7 @@ public class MainPagePanel extends javax.swing.JPanel {
//</editor-fold> //</editor-fold>
// <editor-fold defaultstate="collapsed" desc="Private Variables"> // <editor-fold defaultstate="collapsed" desc="Private Variables">
boolean preaparingAuth = true; boolean preparingAuth = true;
private boolean isLoading = false; private boolean isLoading = false;
private final javax.swing.JPanel pnlButtons; private final javax.swing.JPanel pnlButtons;
private final ConstomButton btnRun; private final ConstomButton btnRun;
@@ -518,12 +518,12 @@ public class MainPagePanel extends javax.swing.JPanel {
}); });
} }
public void onShow(boolean showLeft) { public void onShow(boolean showFirstLoadingMessage) {
if (showLeft) if (showFirstLoadingMessage)
SwingUtilities.invokeLater(() -> MainFrame.INSTANCE.showMessage(C.i18n("ui.message.first_load"))); SwingUtilities.invokeLater(() -> MainFrame.INSTANCE.showMessage(C.i18n("ui.message.first_load")));
if (cboLoginMode.getSelectedIndex() >= 0 && cboLoginMode.getSelectedIndex() < cboLoginMode.getItemCount()) { if (cboLoginMode.getSelectedIndex() >= 0 && cboLoginMode.getSelectedIndex() < cboLoginMode.getItemCount()) {
IAuthenticator l = IAuthenticator.LOGINS.get(cboLoginMode.getSelectedIndex()); IAuthenticator l = IAuthenticator.LOGINS.get(cboLoginMode.getSelectedIndex());
if (!l.isHidePasswordBox() && !l.isLoggedIn()) if (!l.hasPassword() && !l.isLoggedIn())
SwingUtilities.invokeLater(() -> MainFrame.INSTANCE.showMessage(C.i18n("ui.message.enter_password"))); SwingUtilities.invokeLater(() -> MainFrame.INSTANCE.showMessage(C.i18n("ui.message.enter_password")));
} }
} }

View File

@@ -1,18 +1,19 @@
/* /*
* Copyright 2013 huangyuhui <huanghongxun2008@126.com> * Hello Minecraft! Launcher.
* Copyright (C) 2013 huangyuhui <huanghongxun2008@126.com>
* *
* This program is free software; you can redistribute it and/or modify * This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or * the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version. * (at your option) any later version.
* *
* This program is distributed in the hope that it will be useful, * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program. * along with this program. If not, see {http://www.gnu.org/licenses/}.
*/ */
apply plugin: 'me.tatarka.retrolambda' apply plugin: 'me.tatarka.retrolambda'
@@ -35,4 +36,4 @@ buildscript {
retrolambda { retrolambda {
javaVersion = JavaVersion.VERSION_1_6 javaVersion = JavaVersion.VERSION_1_6
} }

View File

@@ -1,18 +1,19 @@
/* /*
* Copyright 2013 huangyuhui <huanghongxun2008@126.com> * Hello Minecraft! Launcher.
* Copyright (C) 2013 huangyuhui <huanghongxun2008@126.com>
* *
* This program is free software; you can redistribute it and/or modify * This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or * the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version. * (at your option) any later version.
* *
* This program is distributed in the hope that it will be useful, * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program. * along with this program. If not, see {http://www.gnu.org/licenses/}.
*/ */
apply plugin: 'launch4j' apply plugin: 'launch4j'
apply plugin: 'me.tatarka.retrolambda' apply plugin: 'me.tatarka.retrolambda'
@@ -77,4 +78,4 @@ processResources {
} }
} }
build.dependsOn makeExecutable build.dependsOn makeExecutable

View File

@@ -1,18 +1,19 @@
/* /*
* Copyright 2013 huangyuhui <huanghongxun2008@126.com> * Hello Minecraft! Launcher.
* Copyright (C) 2013 huangyuhui <huanghongxun2008@126.com>
* *
* This program is free software; you can redistribute it and/or modify * This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or * the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version. * (at your option) any later version.
* *
* This program is distributed in the hope that it will be useful, * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program. * along with this program. If not, see {http://www.gnu.org/licenses/}.
*/ */
apply plugin: 'me.tatarka.retrolambda' apply plugin: 'me.tatarka.retrolambda'

View File

@@ -1,18 +1,19 @@
/* /*
* Copyright 2013 huangyuhui <huanghongxun2008@126.com> * Hello Minecraft! Launcher.
* Copyright (C) 2013 huangyuhui <huanghongxun2008@126.com>
* *
* This program is free software; you can redistribute it and/or modify * This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or * the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version. * (at your option) any later version.
* *
* This program is distributed in the hope that it will be useful, * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program. * along with this program. If not, see {http://www.gnu.org/licenses/}.
*/ */
import org.gradle.api.artifacts.* import org.gradle.api.artifacts.*

View File

@@ -1,18 +1,19 @@
/* /*
* Copyright 2013 huangyuhui <huanghongxun2008@126.com> * Hello Minecraft! Launcher.
* Copyright (C) 2013 huangyuhui <huanghongxun2008@126.com>
* *
* This program is free software; you can redistribute it and/or modify * This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or * the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version. * (at your option) any later version.
* *
* This program is distributed in the hope that it will be useful, * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program. * along with this program. If not, see {http://www.gnu.org/licenses/}.
*/ */
apply plugin: 'java' apply plugin: 'java'
apply plugin: 'maven' apply plugin: 'maven'

View File

@@ -1,18 +1,19 @@
/* /*
* Copyright 2013 huangyuhui <huanghongxun2008@126.com> * Hello Minecraft! Launcher.
* Copyright (C) 2013 huangyuhui <huanghongxun2008@126.com>
* *
* This program is free software; you can redistribute it and/or modify * This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or * the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version. * (at your option) any later version.
* *
* This program is distributed in the hope that it will be useful, * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program. * along with this program. If not, see {http://www.gnu.org/licenses/}.
*/ */
rootProject.name = 'HMCL' rootProject.name = 'HMCL'