mirror of
https://github.com/correl/mage.git
synced 2024-11-15 11:09:30 +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 {
|
||||
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,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;
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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)) {
|
||||
|
|
Loading…
Reference in a new issue