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