fixed several NPEs on server

This commit is contained in:
BetaSteward 2011-10-20 12:49:31 -04:00
parent 621e0fb4b1
commit ca6e1556f0
5 changed files with 16 additions and 7 deletions

View file

@ -65,7 +65,7 @@ public class ChatSession {
}
public void kill(UUID userId) {
if (clients.containsKey(userId)) {
if (userId != null && clients.containsKey(userId)) {
String userName = clients.get(userId);
clients.remove(userId);
broadcast(userName, " has left", MessageColor.BLACK);

View file

@ -451,8 +451,11 @@ public class MageServerImpl implements MageServer {
@Override
public boolean isTableOwner(String sessionId, UUID roomId, UUID tableId) throws MageException {
try {
Session session = SessionManager.getInstance().getSession(sessionId);
if (session != null) {
UUID userId = SessionManager.getInstance().getSession(sessionId).getUserId();
return TableManager.getInstance().isTableOwner(tableId, userId);
}
}
catch (Exception ex) {
handleException(ex);

View file

@ -263,6 +263,7 @@ public class TableController {
else {
player = PlayerFactory.getInstance().createPlayer(playerType, name, options.getRange(), skill);
}
if (player != null)
logger.info("Player created " + player.getId());
return player;
}

View file

@ -119,6 +119,7 @@ public class User {
public synchronized void fireCallback(final ClientCallback call) {
if (isConnected()) {
Session session = SessionManager.getInstance().getSession(sessionId);
if (session != null)
session.fireCallback(call);
}
}

View file

@ -217,12 +217,16 @@ public class TournamentController {
}
public void submitDeck(UUID playerId, Deck deck) {
if (tournamentSessions.containsKey(playerId)) {
tournamentSessions.get(playerId).submitDeck(deck);
}
}
public void updateDeck(UUID playerId, Deck deck) {
if (tournamentSessions.containsKey(playerId)) {
tournamentSessions.get(playerId).updateDeck(deck);
}
}
public void timeout(UUID userId) {
if (userPlayerMap.containsKey(userId)) {