mirror of
https://github.com/HMCL-dev/HMCL.git
synced 2025-09-13 05:46:59 -04:00
each authenticator has its own username now
This commit is contained in:
parent
b82243a9c0
commit
a62848d4fa
2
.gitignore
vendored
2
.gitignore
vendored
@ -22,6 +22,6 @@ hs_err_pid*
|
|||||||
|
|
||||||
HMCLAPI/build/
|
HMCLAPI/build/
|
||||||
HMCL/build/
|
HMCL/build/
|
||||||
HMCL/src/main/org/jackhuang/hellominecraft/launcher/servers/
|
HMCLServer/
|
||||||
HMCSM/build/
|
HMCSM/build/
|
||||||
MetroLookAndFeel/build/
|
MetroLookAndFeel/build/
|
||||||
|
@ -48,13 +48,17 @@ public class DefaultPlugin implements IPlugin {
|
|||||||
public void onRegisterAuthenticators(Consumer<IAuthenticator> apply) {
|
public void onRegisterAuthenticators(Consumer<IAuthenticator> apply) {
|
||||||
String clientToken = Settings.getInstance().getClientToken();
|
String clientToken = Settings.getInstance().getClientToken();
|
||||||
OFFLINE_LOGIN = new OfflineAuthenticator(clientToken);
|
OFFLINE_LOGIN = new OfflineAuthenticator(clientToken);
|
||||||
|
OFFLINE_LOGIN.onLoadSettings(Settings.getInstance().getAuthenticatorConfig(OFFLINE_LOGIN.id()));
|
||||||
YGGDRASIL_LOGIN = new YggdrasilAuthenticator(clientToken);
|
YGGDRASIL_LOGIN = new YggdrasilAuthenticator(clientToken);
|
||||||
YGGDRASIL_LOGIN.onLoadSettings(Settings.getInstance().getYggdrasilConfig());
|
YGGDRASIL_LOGIN.onLoadSettings(Settings.getInstance().getAuthenticatorConfig(YGGDRASIL_LOGIN.id()));
|
||||||
SKINME_LOGIN = new SkinmeAuthenticator(clientToken);
|
SKINME_LOGIN = new SkinmeAuthenticator(clientToken);
|
||||||
|
SKINME_LOGIN.onLoadSettings(Settings.getInstance().getAuthenticatorConfig(SKINME_LOGIN.id()));
|
||||||
|
|
||||||
Runtime.getRuntime().addShutdownHook(new Thread(()
|
Runtime.getRuntime().addShutdownHook(new Thread(() -> {
|
||||||
-> Settings.getInstance().setYggdrasilConfig(YGGDRASIL_LOGIN.onSaveSettings())
|
Settings.getInstance().setAuthenticatorConfig(OFFLINE_LOGIN.id(), OFFLINE_LOGIN.onSaveSettings());
|
||||||
));
|
Settings.getInstance().setAuthenticatorConfig(YGGDRASIL_LOGIN.id(), YGGDRASIL_LOGIN.onSaveSettings());
|
||||||
|
Settings.getInstance().setAuthenticatorConfig(SKINME_LOGIN.id(), SKINME_LOGIN.onSaveSettings());
|
||||||
|
}));
|
||||||
apply.accept(OFFLINE_LOGIN);
|
apply.accept(OFFLINE_LOGIN);
|
||||||
apply.accept(YGGDRASIL_LOGIN);
|
apply.accept(YGGDRASIL_LOGIN);
|
||||||
apply.accept(SKINME_LOGIN);
|
apply.accept(SKINME_LOGIN);
|
||||||
@ -62,7 +66,7 @@ public class DefaultPlugin implements IPlugin {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void showUI() {
|
public void showUI() {
|
||||||
MainFrame.showMainFrame(Settings.isFirstLoading());
|
MainFrame.showMainFrame();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -36,6 +36,7 @@ import org.jackhuang.hellominecraft.launcher.version.MinecraftLibrary;
|
|||||||
import org.jackhuang.hellominecraft.tasks.TaskWindow;
|
import org.jackhuang.hellominecraft.tasks.TaskWindow;
|
||||||
import org.jackhuang.hellominecraft.utils.system.FileUtils;
|
import org.jackhuang.hellominecraft.utils.system.FileUtils;
|
||||||
import org.jackhuang.hellominecraft.utils.MessageBox;
|
import org.jackhuang.hellominecraft.utils.MessageBox;
|
||||||
|
import org.jackhuang.hellominecraft.utils.StrUtils;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
@ -67,7 +68,7 @@ public class MinecraftLoader extends AbstractMinecraftLoader {
|
|||||||
res.add((v.isCanceledWrapper() ? "" : "-mainClass=") + mainClass);
|
res.add((v.isCanceledWrapper() ? "" : "-mainClass=") + mainClass);
|
||||||
|
|
||||||
String arg = v.getSelectedMinecraftVersion().minecraftArguments;
|
String arg = v.getSelectedMinecraftVersion().minecraftArguments;
|
||||||
String[] splitted = org.jackhuang.hellominecraft.utils.StrUtils.tokenize(arg);
|
String[] splitted = StrUtils.tokenize(arg);
|
||||||
|
|
||||||
if (!checkAssetsExist())
|
if (!checkAssetsExist())
|
||||||
if (MessageBox.Show(C.i18n("assets.no_assets"), MessageBox.YES_NO_OPTION) == MessageBox.YES_OPTION) {
|
if (MessageBox.Show(C.i18n("assets.no_assets"), MessageBox.YES_NO_OPTION) == MessageBox.YES_OPTION) {
|
||||||
|
@ -20,6 +20,7 @@ package org.jackhuang.hellominecraft.launcher.settings;
|
|||||||
import org.jackhuang.hellominecraft.launcher.utils.download.DownloadType;
|
import org.jackhuang.hellominecraft.launcher.utils.download.DownloadType;
|
||||||
import com.google.gson.annotations.SerializedName;
|
import com.google.gson.annotations.SerializedName;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.TreeMap;
|
import java.util.TreeMap;
|
||||||
@ -40,8 +41,6 @@ public final class Config {
|
|||||||
private String last;
|
private String last;
|
||||||
@SerializedName("bgpath")
|
@SerializedName("bgpath")
|
||||||
private String bgpath;
|
private String bgpath;
|
||||||
@SerializedName("username")
|
|
||||||
private String username;
|
|
||||||
@SerializedName("clientToken")
|
@SerializedName("clientToken")
|
||||||
private final String clientToken;
|
private final String clientToken;
|
||||||
private String proxyHost, proxyPort, proxyUserName, proxyPassword;
|
private String proxyHost, proxyPort, proxyUserName, proxyPassword;
|
||||||
@ -116,15 +115,6 @@ public final class Config {
|
|||||||
Settings.save();
|
Settings.save();
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getUsername() {
|
|
||||||
return username;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setUsername(String username) {
|
|
||||||
this.username = username;
|
|
||||||
Settings.save();
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getClientToken() {
|
public String getClientToken() {
|
||||||
return clientToken;
|
return clientToken;
|
||||||
}
|
}
|
||||||
@ -163,12 +153,12 @@ public final class Config {
|
|||||||
return configurations;
|
return configurations;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Map getYggdrasilConfig() {
|
public Map getAuthenticatorConfig(String authId) {
|
||||||
return yggdrasil;
|
return auth.get(authId);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setYggdrasilConfig(Map yggdrasil) {
|
public void setAuthenticatorConfig(String authId, Map map) {
|
||||||
this.yggdrasil = yggdrasil;
|
auth.put(authId, map);
|
||||||
Settings.save();
|
Settings.save();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -178,17 +168,17 @@ public final class Config {
|
|||||||
private int downloadtype;
|
private int downloadtype;
|
||||||
@SerializedName("configurations")
|
@SerializedName("configurations")
|
||||||
private TreeMap<String, Profile> configurations;
|
private TreeMap<String, Profile> configurations;
|
||||||
@SerializedName("yggdrasil")
|
@SerializedName("auth")
|
||||||
private Map yggdrasil;
|
private Map<String, Map> auth;
|
||||||
|
|
||||||
public Config() {
|
public Config() {
|
||||||
clientToken = UUID.randomUUID().toString();
|
clientToken = UUID.randomUUID().toString();
|
||||||
username = "";
|
|
||||||
logintype = downloadtype = 0;
|
logintype = downloadtype = 0;
|
||||||
enableShadow = false;
|
enableShadow = false;
|
||||||
enableAnimation = true;
|
enableAnimation = true;
|
||||||
theme = 4;
|
theme = 4;
|
||||||
decorated = OS.os() == OS.LINUX;
|
decorated = OS.os() == OS.LINUX;
|
||||||
|
auth = new HashMap<>();
|
||||||
}
|
}
|
||||||
|
|
||||||
public DownloadType getDownloadSource() {
|
public DownloadType getDownloadSource() {
|
||||||
|
@ -32,7 +32,6 @@ import org.jackhuang.hellominecraft.utils.CollectionUtils;
|
|||||||
import org.jackhuang.hellominecraft.utils.system.FileUtils;
|
import org.jackhuang.hellominecraft.utils.system.FileUtils;
|
||||||
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 org.jackhuang.hellominecraft.utils.StrUtils;
|
|
||||||
import org.jackhuang.hellominecraft.utils.UpdateChecker;
|
import org.jackhuang.hellominecraft.utils.UpdateChecker;
|
||||||
import org.jackhuang.hellominecraft.utils.VersionNumber;
|
import org.jackhuang.hellominecraft.utils.VersionNumber;
|
||||||
import org.jackhuang.hellominecraft.utils.system.Java;
|
import org.jackhuang.hellominecraft.utils.system.Java;
|
||||||
@ -48,7 +47,6 @@ public final class Settings {
|
|||||||
|
|
||||||
public static final File SETTINGS_FILE = new File(IOUtils.currentDir(), "hmcl.json");
|
public static final File SETTINGS_FILE = new File(IOUtils.currentDir(), "hmcl.json");
|
||||||
|
|
||||||
private static boolean isFirstLoading;
|
|
||||||
private static final Config SETTINGS;
|
private static final Config SETTINGS;
|
||||||
public static final UpdateChecker UPDATE_CHECKER = new UpdateChecker(new VersionNumber(Main.VERSION_FIRST, Main.VERSION_SECOND, Main.VERSION_THIRD),
|
public static final UpdateChecker UPDATE_CHECKER = new UpdateChecker(new VersionNumber(Main.VERSION_FIRST, Main.VERSION_SECOND, Main.VERSION_THIRD),
|
||||||
"hmcl");
|
"hmcl");
|
||||||
@ -58,10 +56,6 @@ public final class Settings {
|
|||||||
return SETTINGS;
|
return SETTINGS;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean isFirstLoading() {
|
|
||||||
return isFirstLoading;
|
|
||||||
}
|
|
||||||
|
|
||||||
static {
|
static {
|
||||||
SETTINGS = initSettings();
|
SETTINGS = initSettings();
|
||||||
if (!getProfiles().containsKey(DEFAULT_PROFILE))
|
if (!getProfiles().containsKey(DEFAULT_PROFILE))
|
||||||
@ -82,7 +76,7 @@ public final class Settings {
|
|||||||
|
|
||||||
private static Config initSettings() {
|
private static Config initSettings() {
|
||||||
Config c = new Config();
|
Config c = new Config();
|
||||||
if (SETTINGS_FILE.exists()) {
|
if (SETTINGS_FILE.exists())
|
||||||
try {
|
try {
|
||||||
String str = FileUtils.readFileToString(SETTINGS_FILE);
|
String str = FileUtils.readFileToString(SETTINGS_FILE);
|
||||||
if (str == null || str.trim().equals(""))
|
if (str == null || str.trim().equals(""))
|
||||||
@ -100,11 +94,8 @@ public final class Settings {
|
|||||||
System.exit(1);
|
System.exit(1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
isFirstLoading = StrUtils.isBlank(c.getUsername());
|
else
|
||||||
} else {
|
|
||||||
HMCLog.log("No settings file here, may be first loading.");
|
HMCLog.log("No settings file here, may be first loading.");
|
||||||
isFirstLoading = true;
|
|
||||||
}
|
|
||||||
return c;
|
return c;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -79,6 +79,11 @@ public final class BestLogin extends IAuthenticator {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String id() {
|
||||||
|
return "best";
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getName() {
|
public String getName() {
|
||||||
return "BestLogin";
|
return "BestLogin";
|
||||||
|
@ -18,7 +18,9 @@
|
|||||||
package org.jackhuang.hellominecraft.launcher.utils.auth;
|
package org.jackhuang.hellominecraft.launcher.utils.auth;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
import org.jackhuang.hellominecraft.launcher.api.PluginManager;
|
import org.jackhuang.hellominecraft.launcher.api.PluginManager;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -34,7 +36,7 @@ public abstract class IAuthenticator {
|
|||||||
PluginManager.NOW_PLUGIN.onRegisterAuthenticators(LOGINS::add);
|
PluginManager.NOW_PLUGIN.onRegisterAuthenticators(LOGINS::add);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected String clientToken;
|
protected String clientToken, username;
|
||||||
|
|
||||||
public IAuthenticator(String clientToken) {
|
public IAuthenticator(String clientToken) {
|
||||||
this.clientToken = clientToken;
|
this.clientToken = clientToken;
|
||||||
@ -52,6 +54,8 @@ public abstract class IAuthenticator {
|
|||||||
*/
|
*/
|
||||||
public abstract UserProfileProvider login(LoginInfo info) throws AuthenticationException;
|
public abstract UserProfileProvider login(LoginInfo info) throws AuthenticationException;
|
||||||
|
|
||||||
|
public abstract String id();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @return the name of login method.
|
* @return the name of login method.
|
||||||
@ -78,4 +82,24 @@ public abstract class IAuthenticator {
|
|||||||
public abstract UserProfileProvider loginBySettings() throws AuthenticationException;
|
public abstract UserProfileProvider loginBySettings() throws AuthenticationException;
|
||||||
|
|
||||||
public abstract void logout();
|
public abstract void logout();
|
||||||
|
|
||||||
|
public Map onSaveSettings() {
|
||||||
|
HashMap m = new HashMap();
|
||||||
|
m.put("IAuthenticator_UserName", username);
|
||||||
|
return m;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void onLoadSettings(Map m) {
|
||||||
|
if (m == null)
|
||||||
|
return;
|
||||||
|
username = (String) m.get("IAuthenticator_UserName");
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getUsername() {
|
||||||
|
return username;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setUsername(String s) {
|
||||||
|
username = s;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -49,6 +49,11 @@ public final class OfflineAuthenticator extends IAuthenticator {
|
|||||||
return DigestUtils.md5Hex(str);
|
return DigestUtils.md5Hex(str);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String id() {
|
||||||
|
return "offline";
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getName() {
|
public String getName() {
|
||||||
return C.i18n("login.methods.offline");
|
return C.i18n("login.methods.offline");
|
||||||
|
@ -104,6 +104,11 @@ public final class SkinmeAuthenticator extends IAuthenticator {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String id() {
|
||||||
|
return "skinme";
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getName() {
|
public String getName() {
|
||||||
return "Skinme";
|
return "Skinme";
|
||||||
|
@ -92,16 +92,26 @@ public final class YggdrasilAuthenticator extends IAuthenticator {
|
|||||||
return ua.isLoggedIn();
|
return ua.isLoggedIn();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String id() {
|
||||||
|
return "yggdrasil";
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getName() {
|
public String getName() {
|
||||||
return C.i18n("login.methods.yggdrasil");
|
return C.i18n("login.methods.yggdrasil");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public Map onSaveSettings() {
|
public Map onSaveSettings() {
|
||||||
return ua.saveForStorage();
|
Map m = ua.saveForStorage();
|
||||||
|
m.putAll(super.onSaveSettings());
|
||||||
|
return m;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void onLoadSettings(Map settings) {
|
public void onLoadSettings(Map settings) {
|
||||||
|
super.onLoadSettings(settings);
|
||||||
if (settings == null)
|
if (settings == null)
|
||||||
return;
|
return;
|
||||||
ua.loadFromStorage(settings);
|
ua.loadFromStorage(settings);
|
||||||
|
@ -1241,7 +1241,7 @@ public final class GameSettingsPanel extends AnimatedPanel implements DropTarget
|
|||||||
// <editor-fold defaultstate="collapsed" desc="Mods">
|
// <editor-fold defaultstate="collapsed" desc="Mods">
|
||||||
private boolean reloadingMods = false;
|
private boolean reloadingMods = false;
|
||||||
|
|
||||||
private void reloadMods() {
|
private synchronized void reloadMods() {
|
||||||
if (reloadingMods)
|
if (reloadingMods)
|
||||||
return;
|
return;
|
||||||
reloadingMods = true;
|
reloadingMods = true;
|
||||||
@ -1343,6 +1343,6 @@ public final class GameSettingsPanel extends AnimatedPanel implements DropTarget
|
|||||||
private javax.swing.JTextField txtWidth;
|
private javax.swing.JTextField txtWidth;
|
||||||
// End of variables declaration//GEN-END:variables
|
// End of variables declaration//GEN-END:variables
|
||||||
|
|
||||||
private javax.swing.JPanel pnlGameDownloads;
|
private final javax.swing.JPanel pnlGameDownloads;
|
||||||
// </editor-fold>
|
// </editor-fold>
|
||||||
}
|
}
|
||||||
|
@ -47,6 +47,7 @@ import org.jackhuang.hellominecraft.launcher.settings.Settings;
|
|||||||
import org.jackhuang.hellominecraft.launcher.utils.auth.IAuthenticator;
|
import org.jackhuang.hellominecraft.launcher.utils.auth.IAuthenticator;
|
||||||
import org.jackhuang.hellominecraft.lookandfeel.GraphicsUtils;
|
import org.jackhuang.hellominecraft.lookandfeel.GraphicsUtils;
|
||||||
import org.jackhuang.hellominecraft.lookandfeel.Theme;
|
import org.jackhuang.hellominecraft.lookandfeel.Theme;
|
||||||
|
import org.jackhuang.hellominecraft.utils.StrUtils;
|
||||||
import org.jackhuang.hellominecraft.utils.Utils;
|
import org.jackhuang.hellominecraft.utils.Utils;
|
||||||
import org.jackhuang.hellominecraft.views.DropShadowBorder;
|
import org.jackhuang.hellominecraft.views.DropShadowBorder;
|
||||||
import org.jackhuang.hellominecraft.views.TintablePanel;
|
import org.jackhuang.hellominecraft.views.TintablePanel;
|
||||||
@ -388,10 +389,10 @@ public final class MainFrame extends DraggableFrame {
|
|||||||
windowTitle.setForeground(Color.white);
|
windowTitle.setForeground(Color.white);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void showMainFrame(boolean firstLoad) {
|
public static void showMainFrame() {
|
||||||
if (firstLoad)
|
|
||||||
SwingUtilities.invokeLater(() -> MainFrame.INSTANCE.showMessage(C.i18n("ui.message.first_load")));
|
|
||||||
IAuthenticator l = Settings.getInstance().getAuthenticator();
|
IAuthenticator l = Settings.getInstance().getAuthenticator();
|
||||||
|
if (StrUtils.isBlank(l.getUsername()))
|
||||||
|
SwingUtilities.invokeLater(() -> MainFrame.INSTANCE.showMessage(C.i18n("ui.message.first_load")));
|
||||||
if (l.hasPassword() && !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")));
|
||||||
INSTANCE.setVisible(true);
|
INSTANCE.setVisible(true);
|
||||||
|
@ -297,7 +297,8 @@ public class MainPagePanel extends AnimatedPanel implements Event<String> {
|
|||||||
}//GEN-LAST:event_txtPlayerNameFocusGained
|
}//GEN-LAST:event_txtPlayerNameFocusGained
|
||||||
|
|
||||||
private void txtPlayerNameFocusLost(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_txtPlayerNameFocusLost
|
private void txtPlayerNameFocusLost(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_txtPlayerNameFocusLost
|
||||||
Settings.getInstance().setUsername(txtPlayerName.getText());
|
IAuthenticator l = Settings.getInstance().getAuthenticator();
|
||||||
|
l.setUsername(txtPlayerName.getText());
|
||||||
}//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
|
||||||
@ -350,8 +351,8 @@ public class MainPagePanel extends AnimatedPanel implements Event<String> {
|
|||||||
|
|
||||||
private void txtPlayerNameKeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_txtPlayerNameKeyPressed
|
private void txtPlayerNameKeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_txtPlayerNameKeyPressed
|
||||||
if (evt.getKeyCode() == KeyEvent.VK_ENTER) {
|
if (evt.getKeyCode() == KeyEvent.VK_ENTER) {
|
||||||
Settings.getInstance().setUsername(txtPlayerName.getText());
|
|
||||||
IAuthenticator l = Settings.getInstance().getAuthenticator();
|
IAuthenticator l = Settings.getInstance().getAuthenticator();
|
||||||
|
l.setUsername(txtPlayerName.getText());
|
||||||
if (!l.hasPassword())
|
if (!l.hasPassword())
|
||||||
runGame();
|
runGame();
|
||||||
else if (!l.isLoggedIn())
|
else if (!l.isLoggedIn())
|
||||||
@ -400,7 +401,7 @@ public class MainPagePanel extends AnimatedPanel implements Event<String> {
|
|||||||
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.hasPassword() ? null : new String(txtPassword.getPassword()));
|
final LoginInfo li = new LoginInfo(l.getUsername(), l.isLoggedIn() || !l.hasPassword() ? null : new String(txtPassword.getPassword()));
|
||||||
new Thread() {
|
new Thread() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
@ -458,9 +459,10 @@ public class MainPagePanel extends AnimatedPanel implements Event<String> {
|
|||||||
cl.last(pnlPassword);
|
cl.last(pnlPassword);
|
||||||
else
|
else
|
||||||
cl.first(pnlPassword);
|
cl.first(pnlPassword);
|
||||||
String username = Settings.getInstance().getUsername();
|
String username = l.getUsername();
|
||||||
if (StrUtils.isNotBlank(username))
|
if (username == null)
|
||||||
txtPlayerName.setText(username);
|
username = "";
|
||||||
|
txtPlayerName.setText(username);
|
||||||
}
|
}
|
||||||
|
|
||||||
void loadFromSettings() {
|
void loadFromSettings() {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user