mirror of
https://github.com/magefree/mage.git
synced 2025-12-22 11:32:00 -08:00
Fixed some possible NPE in MageServerImpl (Fixes #342).
This commit is contained in:
parent
dc5fc69287
commit
faafa3f8be
1 changed files with 24 additions and 4 deletions
|
|
@ -219,7 +219,12 @@ public class MageServerImpl implements MageServer {
|
||||||
//FIXME: why no sessionId here???
|
//FIXME: why no sessionId here???
|
||||||
public List<TableView> getTables(UUID roomId) throws MageException {
|
public List<TableView> getTables(UUID roomId) throws MageException {
|
||||||
try {
|
try {
|
||||||
return GamesRoomManager.getInstance().getRoom(roomId).getTables();
|
GamesRoom room = GamesRoomManager.getInstance().getRoom(roomId);
|
||||||
|
if (room != null) {
|
||||||
|
return room.getTables();
|
||||||
|
} else {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
catch (Exception ex) {
|
catch (Exception ex) {
|
||||||
handleException(ex);
|
handleException(ex);
|
||||||
|
|
@ -231,7 +236,12 @@ public class MageServerImpl implements MageServer {
|
||||||
//FIXME: why no sessionId here???
|
//FIXME: why no sessionId here???
|
||||||
public List<MatchView> getFinishedMatches(UUID roomId) throws MageException {
|
public List<MatchView> getFinishedMatches(UUID roomId) throws MageException {
|
||||||
try {
|
try {
|
||||||
return GamesRoomManager.getInstance().getRoom(roomId).getFinished();
|
GamesRoom room = GamesRoomManager.getInstance().getRoom(roomId);
|
||||||
|
if (room != null) {
|
||||||
|
return room.getFinished();
|
||||||
|
} else {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
catch (Exception ex) {
|
catch (Exception ex) {
|
||||||
handleException(ex);
|
handleException(ex);
|
||||||
|
|
@ -243,7 +253,12 @@ public class MageServerImpl implements MageServer {
|
||||||
//FIXME: why no sessionId here???
|
//FIXME: why no sessionId here???
|
||||||
public List<String> getConnectedPlayers(UUID roomId) throws MageException {
|
public List<String> getConnectedPlayers(UUID roomId) throws MageException {
|
||||||
try {
|
try {
|
||||||
return GamesRoomManager.getInstance().getRoom(roomId).getPlayers();
|
GamesRoom room = GamesRoomManager.getInstance().getRoom(roomId);
|
||||||
|
if (room != null) {
|
||||||
|
return room.getPlayers();
|
||||||
|
} else {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
catch (Exception ex) {
|
catch (Exception ex) {
|
||||||
handleException(ex);
|
handleException(ex);
|
||||||
|
|
@ -255,7 +270,12 @@ public class MageServerImpl implements MageServer {
|
||||||
//FIXME: why no sessionId here???
|
//FIXME: why no sessionId here???
|
||||||
public TableView getTable(UUID roomId, UUID tableId) throws MageException {
|
public TableView getTable(UUID roomId, UUID tableId) throws MageException {
|
||||||
try {
|
try {
|
||||||
return GamesRoomManager.getInstance().getRoom(roomId).getTable(tableId);
|
GamesRoom room = GamesRoomManager.getInstance().getRoom(roomId);
|
||||||
|
if (room != null) {
|
||||||
|
return room.getTable(tableId);
|
||||||
|
} else {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
catch (Exception ex) {
|
catch (Exception ex) {
|
||||||
handleException(ex);
|
handleException(ex);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue