mirror of
https://github.com/correl/mage.git
synced 2024-11-25 03:00:11 +00:00
Merge pull request #2836 from spjspj/master
Add field for server console
This commit is contained in:
commit
9fe53e52c2
11 changed files with 57 additions and 25 deletions
|
@ -26,7 +26,7 @@
|
|||
* or implied, of BetaSteward_at_googlemail.com.
|
||||
*/
|
||||
|
||||
/*
|
||||
/*
|
||||
* ConnectDialog.java
|
||||
*
|
||||
* Created on 20-Jan-2010, 9:37:07 PM
|
||||
|
@ -391,6 +391,7 @@ public class ConnectDialog extends MageDialog {
|
|||
connection.setUsername(this.txtUserName.getText().trim());
|
||||
connection.setPassword(this.txtPassword.getText().trim());
|
||||
connection.setForceDBComparison(this.chkForceUpdateDB.isSelected());
|
||||
connection.setUserIdStr(System.getProperty("user.name"));
|
||||
MageFrame.getPreferences().put(KEY_CONNECT_FLAG, ((CountryItemEditor) cbFlag.getEditor()).getImageItem());
|
||||
PreferencesDialog.setProxyInformation(connection);
|
||||
|
||||
|
|
|
@ -3520,6 +3520,7 @@ public class PreferencesDialog extends javax.swing.JDialog {
|
|||
if (selectedAvatarId == 0) {
|
||||
getSelectedAvatar();
|
||||
}
|
||||
String userStrId = System.getProperty("user.name");
|
||||
return new UserData(UserGroup.PLAYER,
|
||||
PreferencesDialog.selectedAvatarId,
|
||||
PreferencesDialog.getCachedValue(PreferencesDialog.KEY_SHOW_ABILITY_PICKER_FORCED, "true").equals("true"),
|
||||
|
@ -3533,7 +3534,8 @@ public class PreferencesDialog extends javax.swing.JDialog {
|
|||
PreferencesDialog.getCachedValue(PreferencesDialog.KEY_PASS_PRIORITY_CAST, "true").equals("true"),
|
||||
PreferencesDialog.getCachedValue(PreferencesDialog.KEY_PASS_PRIORITY_ACTIVATION, "true").equals("true"),
|
||||
PreferencesDialog.getCachedValue(PreferencesDialog.KEY_AUTO_ORDER_TRIGGER, "true").equals("true"),
|
||||
PreferencesDialog.getCachedValue(PreferencesDialog.KEY_USE_FIRST_MANA_ABILITY, "false").equals("true")
|
||||
PreferencesDialog.getCachedValue(PreferencesDialog.KEY_USE_FIRST_MANA_ABILITY, "false").equals("true"),
|
||||
userStrId
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
@ -62,7 +62,7 @@ public interface MageServer {
|
|||
|
||||
boolean resetPassword(String sessionId, String email, String authToken, String password) throws MageException;
|
||||
|
||||
boolean connectUser(String userName, String password, String sessionId, MageVersion version) throws MageException;
|
||||
boolean connectUser(String userName, String password, String sessionId, MageVersion version, String userIdStr) throws MageException;
|
||||
|
||||
boolean connectAdmin(String password, String sessionId, MageVersion version) throws MageException;
|
||||
|
||||
|
@ -72,7 +72,7 @@ public interface MageServer {
|
|||
List<CardInfo> getMissingCardsData(List<String> classNames);
|
||||
|
||||
// user methods
|
||||
boolean setUserData(String userName, String sessionId, UserData userData, String clientVersion) throws MageException;
|
||||
boolean setUserData(String userName, String sessionId, UserData userData, String clientVersion, String userIdStr) throws MageException;
|
||||
|
||||
void sendFeedbackMessage(String sessionId, String username, String title, String type, String message, String email) throws MageException;
|
||||
|
||||
|
|
|
@ -55,6 +55,7 @@ public class Connection {
|
|||
private String proxyPassword;
|
||||
private int clientCardDatabaseVersion;
|
||||
private boolean forceDBComparison;
|
||||
private String userIdStr;
|
||||
|
||||
private UserData userData;
|
||||
|
||||
|
@ -167,6 +168,14 @@ public class Connection {
|
|||
this.username = username;
|
||||
}
|
||||
|
||||
public String getUserIdStr() {
|
||||
return userIdStr;
|
||||
}
|
||||
|
||||
public void setUserIdStr(String userIdStr) {
|
||||
this.userIdStr = userIdStr;
|
||||
}
|
||||
|
||||
public String getPassword() {
|
||||
return password;
|
||||
}
|
||||
|
|
|
@ -222,9 +222,9 @@ public class SessionImpl implements Session {
|
|||
boolean registerResult;
|
||||
if (connection.getAdminPassword() == null) {
|
||||
// for backward compatibility. don't remove twice call - first one does nothing but for version checking
|
||||
registerResult = server.connectUser(connection.getUsername(), connection.getPassword(), sessionId, client.getVersion());
|
||||
registerResult = server.connectUser(connection.getUsername(), connection.getPassword(), sessionId, client.getVersion(), connection.getUserIdStr());
|
||||
if (registerResult) {
|
||||
server.setUserData(connection.getUsername(), sessionId, connection.getUserData(), client.getVersion().toString());
|
||||
server.setUserData(connection.getUsername(), sessionId, connection.getUserData(), client.getVersion().toString(), connection.getUserIdStr());
|
||||
}
|
||||
} else {
|
||||
registerResult = server.connectAdmin(connection.getAdminPassword(), sessionId, client.getVersion());
|
||||
|
@ -1466,7 +1466,7 @@ public class SessionImpl implements Session {
|
|||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean setActivation(String userName, boolean active) {
|
||||
try {
|
||||
|
@ -1571,7 +1571,7 @@ public class SessionImpl implements Session {
|
|||
public boolean updatePreferencesForServer(UserData userData) {
|
||||
try {
|
||||
if (isConnected()) {
|
||||
server.setUserData(connection.getUsername(), sessionId, userData, null);
|
||||
server.setUserData(connection.getUsername(), sessionId, userData, null, null);
|
||||
}
|
||||
return true;
|
||||
} catch (MageException ex) {
|
||||
|
|
|
@ -46,8 +46,9 @@ public class UserView implements Serializable {
|
|||
private final Date muteChatUntil;
|
||||
private final String clientVersion;
|
||||
private final String email;
|
||||
private final String userIdStr;
|
||||
|
||||
public UserView(String userName, String host, String sessionId, Date timeConnected, String gameInfo, String userState, Date muteChatUntil, String clientVersion, String email) {
|
||||
public UserView(String userName, String host, String sessionId, Date timeConnected, String gameInfo, String userState, Date muteChatUntil, String clientVersion, String email, String userIdStr) {
|
||||
this.userName = userName;
|
||||
this.host = host;
|
||||
this.sessionId = sessionId;
|
||||
|
@ -57,6 +58,7 @@ public class UserView implements Serializable {
|
|||
this.muteChatUntil = muteChatUntil;
|
||||
this.clientVersion = clientVersion;
|
||||
this.email = email;
|
||||
this.userIdStr = userIdStr;
|
||||
}
|
||||
|
||||
public String getUserName() {
|
||||
|
@ -90,9 +92,12 @@ public class UserView implements Serializable {
|
|||
public Date getTimeConnected() {
|
||||
return timeConnected;
|
||||
}
|
||||
|
||||
|
||||
public String getEmail() {
|
||||
return email;
|
||||
}
|
||||
|
||||
public String getUserIdStr() {
|
||||
return userIdStr;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -132,7 +132,7 @@ public class MageServerImpl implements MageServer {
|
|||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean resetPassword(String sessionId, String email, String authToken, String password) throws MageException {
|
||||
if (!ConfigSettings.getInstance().isAuthenticationActivated()) {
|
||||
|
@ -158,13 +158,13 @@ public class MageServerImpl implements MageServer {
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean connectUser(String userName, String password, String sessionId, MageVersion version) throws MageException {
|
||||
public boolean connectUser(String userName, String password, String sessionId, MageVersion version, String userIdStr) throws MageException {
|
||||
try {
|
||||
if (version.compareTo(Main.getVersion()) != 0) {
|
||||
logger.info("MageVersionException: userName=" + userName + ", version=" + version);
|
||||
throw new MageVersionException(version, Main.getVersion());
|
||||
}
|
||||
return SessionManager.getInstance().connectUser(sessionId, userName, password);
|
||||
return SessionManager.getInstance().connectUser(sessionId, userName, password, userIdStr);
|
||||
} catch (MageException ex) {
|
||||
if (ex instanceof MageVersionException) {
|
||||
throw (MageVersionException) ex;
|
||||
|
@ -175,11 +175,11 @@ public class MageServerImpl implements MageServer {
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean setUserData(final String userName, final String sessionId, final UserData userData, final String clientVersion) throws MageException {
|
||||
public boolean setUserData(final String userName, final String sessionId, final UserData userData, final String clientVersion, final String userIdStr) throws MageException {
|
||||
return executeWithResult("setUserData", sessionId, new ActionWithBooleanResult() {
|
||||
@Override
|
||||
public Boolean execute() throws MageException {
|
||||
return SessionManager.getInstance().setUserData(userName, sessionId, userData, clientVersion);
|
||||
return SessionManager.getInstance().setUserData(userName, sessionId, userData, clientVersion, userIdStr);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@ -943,7 +943,8 @@ public class MageServerImpl implements MageServer {
|
|||
user.getUserState().toString(),
|
||||
user.getChatLockedUntil(),
|
||||
user.getClientVersion(),
|
||||
user.getEmail()
|
||||
user.getEmail(),
|
||||
user.getUserIdStr()
|
||||
));
|
||||
}
|
||||
return users;
|
||||
|
|
|
@ -264,12 +264,13 @@ public class Session {
|
|||
this.userId = user.getId();
|
||||
}
|
||||
|
||||
public boolean setUserData(String userName, UserData userData, String clientVersion) {
|
||||
public boolean setUserData(String userName, UserData userData, String clientVersion, String userIdStr) {
|
||||
User user = UserManager.getInstance().getUserByName(userName);
|
||||
if (user != null) {
|
||||
if (clientVersion != null) {
|
||||
user.setClientVersion(clientVersion);
|
||||
}
|
||||
user.setUserIdStr(userIdStr);
|
||||
if (user.getUserData() == null || user.getUserData().getGroupId() == UserGroup.DEFAULT.getGroupId()) {
|
||||
user.setUserData(userData);
|
||||
} else {
|
||||
|
|
|
@ -88,7 +88,7 @@ public class SessionManager {
|
|||
return true;
|
||||
}
|
||||
|
||||
public boolean connectUser(String sessionId, String userName, String password) throws MageException {
|
||||
public boolean connectUser(String sessionId, String userName, String password, String userIdStr) throws MageException {
|
||||
Session session = sessions.get(sessionId);
|
||||
if (session != null) {
|
||||
String returnMessage = session.connectUser(userName, password);
|
||||
|
@ -117,10 +117,10 @@ public class SessionManager {
|
|||
return false;
|
||||
}
|
||||
|
||||
public boolean setUserData(String userName, String sessionId, UserData userData, String clientVersion) throws MageException {
|
||||
public boolean setUserData(String userName, String sessionId, UserData userData, String clientVersion, String userIdStr) throws MageException {
|
||||
Session session = sessions.get(sessionId);
|
||||
if (session != null) {
|
||||
session.setUserData(userName, userData, clientVersion);
|
||||
session.setUserData(userName, userData, clientVersion, userIdStr);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
@ -217,7 +217,7 @@ public class SessionManager {
|
|||
if (session != null) {
|
||||
return UserManager.getInstance().getUser(sessions.get(sessionId).getUserId());
|
||||
}
|
||||
logger.error(String.format("Session %s could not be found",sessionId));
|
||||
logger.error(String.format("Session %s could not be found", sessionId));
|
||||
return Optional.empty();
|
||||
}
|
||||
|
||||
|
|
|
@ -96,6 +96,7 @@ public class User {
|
|||
private Date lockedUntil;
|
||||
private final AuthorizedUser authorizedUser;
|
||||
private String clientVersion;
|
||||
private String userIdStr;
|
||||
|
||||
public User(String userName, String host, AuthorizedUser authorizedUser) {
|
||||
this.userId = UUID.randomUUID();
|
||||
|
@ -127,6 +128,7 @@ public class User {
|
|||
this.tablesToDelete = new ArrayList<>();
|
||||
this.sessionId = "";
|
||||
this.clientVersion = "";
|
||||
this.userIdStr = "";
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
|
@ -178,6 +180,14 @@ public class User {
|
|||
this.clientVersion = clientVersion;
|
||||
}
|
||||
|
||||
public void setUserIdStr(String userIdStr) {
|
||||
this.userIdStr = userIdStr;
|
||||
}
|
||||
|
||||
public String getUserIdStr() {
|
||||
return this.userIdStr;
|
||||
}
|
||||
|
||||
public String getClientVersion() {
|
||||
return clientVersion;
|
||||
}
|
||||
|
@ -199,7 +209,7 @@ public class User {
|
|||
|
||||
public void lostConnection() {
|
||||
// Because watched games don't get restored after reconnection call stop watching
|
||||
for (Iterator<UUID> iterator = watchedGames.iterator(); iterator.hasNext(); ) {
|
||||
for (Iterator<UUID> iterator = watchedGames.iterator(); iterator.hasNext();) {
|
||||
UUID gameId = iterator.next();
|
||||
GameManager.getInstance().stopWatching(gameId, userId);
|
||||
iterator.remove();
|
||||
|
@ -781,7 +791,7 @@ public class User {
|
|||
}
|
||||
return number;
|
||||
}
|
||||
|
||||
|
||||
public String getEmail() {
|
||||
if (authorizedUser != null) {
|
||||
return authorizedUser.email;
|
||||
|
|
|
@ -23,6 +23,7 @@ public class UserData implements Serializable {
|
|||
protected boolean passPriorityActivation;
|
||||
protected boolean autoOrderTrigger;
|
||||
protected boolean useFirstManaAbility = false;
|
||||
private String userIdStr;
|
||||
|
||||
protected String matchHistory;
|
||||
protected int matchQuitRatio;
|
||||
|
@ -36,7 +37,7 @@ public class UserData implements Serializable {
|
|||
public UserData(UserGroup userGroup, int avatarId, boolean showAbilityPickerForced,
|
||||
boolean allowRequestShowHandCards, boolean confirmEmptyManaPool, UserSkipPrioritySteps userSkipPrioritySteps,
|
||||
String flagName, boolean askMoveToGraveOrder, boolean manaPoolAutomatic, boolean manaPoolAutomaticRestricted,
|
||||
boolean passPriorityCast, boolean passPriorityActivation, boolean autoOrderTrigger, boolean useFirstManaAbility) {
|
||||
boolean passPriorityCast, boolean passPriorityActivation, boolean autoOrderTrigger, boolean useFirstManaAbility, String userIdStr) {
|
||||
this.groupId = userGroup.getGroupId();
|
||||
this.avatarId = avatarId;
|
||||
this.showAbilityPickerForced = showAbilityPickerForced;
|
||||
|
@ -55,6 +56,7 @@ public class UserData implements Serializable {
|
|||
this.matchQuitRatio = 0;
|
||||
this.tourneyHistory = "";
|
||||
this.tourneyQuitRatio = 0;
|
||||
this.userIdStr = userIdStr;
|
||||
}
|
||||
|
||||
public void update(UserData userData) {
|
||||
|
@ -72,11 +74,12 @@ public class UserData implements Serializable {
|
|||
this.passPriorityActivation = userData.passPriorityActivation;
|
||||
this.autoOrderTrigger = userData.autoOrderTrigger;
|
||||
this.useFirstManaAbility = userData.useFirstManaAbility;
|
||||
this.userIdStr = userData.userIdStr;
|
||||
// todo: why we don't copy user stats here?
|
||||
}
|
||||
|
||||
public static UserData getDefaultUserDataView() {
|
||||
return new UserData(UserGroup.DEFAULT, 0, false, false, true, null, getDefaultFlagName(), false, true, true, false, false, false, false);
|
||||
return new UserData(UserGroup.DEFAULT, 0, false, false, true, null, getDefaultFlagName(), false, true, true, false, false, false, false, "");
|
||||
}
|
||||
|
||||
public void setGroupId(int groupId) {
|
||||
|
|
Loading…
Reference in a new issue