mirror of
https://github.com/correl/mage.git
synced 2024-12-25 03:00:15 +00:00
fixed several NPEs on server
This commit is contained in:
parent
621e0fb4b1
commit
ca6e1556f0
5 changed files with 16 additions and 7 deletions
|
@ -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);
|
||||
|
|
|
@ -451,8 +451,11 @@ public class MageServerImpl implements MageServer {
|
|||
@Override
|
||||
public boolean isTableOwner(String sessionId, UUID roomId, UUID tableId) throws MageException {
|
||||
try {
|
||||
UUID userId = SessionManager.getInstance().getSession(sessionId).getUserId();
|
||||
return TableManager.getInstance().isTableOwner(tableId, userId);
|
||||
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);
|
||||
|
|
|
@ -263,7 +263,8 @@ public class TableController {
|
|||
else {
|
||||
player = PlayerFactory.getInstance().createPlayer(playerType, name, options.getRange(), skill);
|
||||
}
|
||||
logger.info("Player created " + player.getId());
|
||||
if (player != null)
|
||||
logger.info("Player created " + player.getId());
|
||||
return player;
|
||||
}
|
||||
|
||||
|
|
|
@ -119,7 +119,8 @@ public class User {
|
|||
public synchronized void fireCallback(final ClientCallback call) {
|
||||
if (isConnected()) {
|
||||
Session session = SessionManager.getInstance().getSession(sessionId);
|
||||
session.fireCallback(call);
|
||||
if (session != null)
|
||||
session.fireCallback(call);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -217,11 +217,15 @@ public class TournamentController {
|
|||
}
|
||||
|
||||
public void submitDeck(UUID playerId, Deck deck) {
|
||||
tournamentSessions.get(playerId).submitDeck(deck);
|
||||
if (tournamentSessions.containsKey(playerId)) {
|
||||
tournamentSessions.get(playerId).submitDeck(deck);
|
||||
}
|
||||
}
|
||||
|
||||
public void updateDeck(UUID playerId, Deck deck) {
|
||||
tournamentSessions.get(playerId).updateDeck(deck);
|
||||
if (tournamentSessions.containsKey(playerId)) {
|
||||
tournamentSessions.get(playerId).updateDeck(deck);
|
||||
}
|
||||
}
|
||||
|
||||
public void timeout(UUID userId) {
|
||||
|
|
Loading…
Reference in a new issue