mirror of
https://github.com/correl/mage.git
synced 2024-12-25 11:11:16 +00:00
[minor] Some formatting, remove unused code, changes to logging.
This commit is contained in:
parent
7df016ecf8
commit
31da9dcdfd
4 changed files with 10 additions and 13 deletions
|
@ -44,9 +44,7 @@ public class GameClientMessage implements Serializable {
|
||||||
private CardsView cardsView;
|
private CardsView cardsView;
|
||||||
private CardsView cardsView2;
|
private CardsView cardsView2;
|
||||||
private String message;
|
private String message;
|
||||||
private AbilityPickerView abilityView;
|
|
||||||
private boolean flag;
|
private boolean flag;
|
||||||
private boolean cancel;
|
|
||||||
private String[] strings;
|
private String[] strings;
|
||||||
private Set<UUID> targets;
|
private Set<UUID> targets;
|
||||||
private int min;
|
private int min;
|
||||||
|
@ -109,10 +107,6 @@ public class GameClientMessage implements Serializable {
|
||||||
return message;
|
return message;
|
||||||
}
|
}
|
||||||
|
|
||||||
public AbilityPickerView getAbilityView() {
|
|
||||||
return abilityView;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isFlag() {
|
public boolean isFlag() {
|
||||||
return flag;
|
return flag;
|
||||||
}
|
}
|
||||||
|
|
|
@ -70,8 +70,9 @@ public class Session {
|
||||||
|
|
||||||
public void registerUser(String userName) throws MageException {
|
public void registerUser(String userName) throws MageException {
|
||||||
this.isAdmin = false;
|
this.isAdmin = false;
|
||||||
if (userName.equals("Admin"))
|
if (userName.equals("Admin")) {
|
||||||
throw new MageException("User name already in use");
|
throw new MageException("User name already in use");
|
||||||
|
}
|
||||||
if (userName.length() > ConfigSettings.getInstance().getMaxUserNameLength()) {
|
if (userName.length() > ConfigSettings.getInstance().getMaxUserNameLength()) {
|
||||||
throw new MageException(new StringBuilder("User name may not be longer than ").append(ConfigSettings.getInstance().getMaxUserNameLength()).append(" characters").toString());
|
throw new MageException(new StringBuilder("User name may not be longer than ").append(ConfigSettings.getInstance().getMaxUserNameLength()).append(" characters").toString());
|
||||||
}
|
}
|
||||||
|
@ -87,8 +88,9 @@ public class Session {
|
||||||
if (user == null) { // user already exists
|
if (user == null) { // user already exists
|
||||||
user = UserManager.getInstance().findUser(userName);
|
user = UserManager.getInstance().findUser(userName);
|
||||||
if (user.getHost().equals(host)) {
|
if (user.getHost().equals(host)) {
|
||||||
if (user.getSessionId().isEmpty())
|
if (user.getSessionId().isEmpty()) {
|
||||||
logger.info("Reconnecting session for " + userName);
|
logger.info("Reconnecting session for " + userName);
|
||||||
|
}
|
||||||
else {
|
else {
|
||||||
//throw new MageException("This machine is already connected");
|
//throw new MageException("This machine is already connected");
|
||||||
//disconnect previous one
|
//disconnect previous one
|
||||||
|
@ -100,8 +102,9 @@ public class Session {
|
||||||
throw new MageException("User name already in use");
|
throw new MageException("User name already in use");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!UserManager.getInstance().connectToSession(sessionId, user.getId()))
|
if (!UserManager.getInstance().connectToSession(sessionId, user.getId())) {
|
||||||
throw new MageException("Error connecting");
|
throw new MageException("Error connecting");
|
||||||
|
}
|
||||||
this.userId = user.getId();
|
this.userId = user.getId();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -102,14 +102,14 @@ public class User {
|
||||||
this.sessionId = sessionId;
|
this.sessionId = sessionId;
|
||||||
if (sessionId.isEmpty()) {
|
if (sessionId.isEmpty()) {
|
||||||
userState = UserState.Disconnected;
|
userState = UserState.Disconnected;
|
||||||
logger.info(new StringBuilder("User ").append(userName).append(" disconnected").toString());
|
logger.info(new StringBuilder("User ").append(userName).append(" disconnected - userId = ").append(userId.toString()).toString());
|
||||||
} else if (userState == UserState.Created) {
|
} else if (userState == UserState.Created) {
|
||||||
userState = UserState.Connected;
|
userState = UserState.Connected;
|
||||||
logger.info(new StringBuilder("User ").append(userName).append(" created").toString());
|
logger.info(new StringBuilder("User ").append(userName).append(" created - userId = ").append(userId.toString()).toString());
|
||||||
} else {
|
} else {
|
||||||
userState = UserState.Reconnected;
|
userState = UserState.Reconnected;
|
||||||
reconnect();
|
reconnect();
|
||||||
logger.info(new StringBuilder("User ").append(userName).append(" reconnected").toString());
|
logger.info(new StringBuilder("User ").append(userName).append(" reconnected - userId = ").append(userId.toString()).toString());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -120,7 +120,7 @@ public class UserManager {
|
||||||
|
|
||||||
public void removeUser(UUID userId, User.DisconnectReason reason) {
|
public void removeUser(UUID userId, User.DisconnectReason reason) {
|
||||||
if (users.containsKey(userId)) {
|
if (users.containsKey(userId)) {
|
||||||
logger.info("user removed" + userId);
|
logger.info("user removed " + userId);
|
||||||
ChatManager.getInstance().removeUser(userId, reason);
|
ChatManager.getInstance().removeUser(userId, reason);
|
||||||
ChatManager.getInstance().broadcast(userId, "has disconnected", MessageColor.BLACK);
|
ChatManager.getInstance().broadcast(userId, "has disconnected", MessageColor.BLACK);
|
||||||
users.get(userId).kill(User.DisconnectReason.Disconnected);
|
users.get(userId).kill(User.DisconnectReason.Disconnected);
|
||||||
|
|
Loading…
Reference in a new issue