forked from External/mage
rewrites to optionals
This commit is contained in:
parent
348faa345b
commit
ff6c6405aa
28 changed files with 760 additions and 494 deletions
|
|
@ -28,6 +28,7 @@
|
|||
|
||||
package mage.server.game;
|
||||
|
||||
import java.util.Optional;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import mage.cards.decks.DeckCardLists;
|
||||
|
|
@ -59,12 +60,12 @@ public enum GameManager {
|
|||
}
|
||||
}
|
||||
|
||||
public UUID getChatId(UUID gameId) {
|
||||
public Optional<UUID> getChatId(UUID gameId) {
|
||||
GameController gameController = gameControllers.get(gameId);
|
||||
if (gameController != null) {
|
||||
return gameController.getChatId();
|
||||
return Optional.of(gameController.getChatId());
|
||||
}
|
||||
return null;
|
||||
return Optional.empty();
|
||||
}
|
||||
|
||||
public void sendPlayerUUID(UUID gameId, UUID userId, UUID data) {
|
||||
|
|
|
|||
|
|
@ -29,6 +29,7 @@
|
|||
package mage.server.game;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
import java.util.UUID;
|
||||
import mage.MageException;
|
||||
import mage.cards.decks.DeckCardLists;
|
||||
|
|
@ -55,7 +56,7 @@ public interface GamesRoom extends Room {
|
|||
TableView createTournamentTable(UUID userId, TournamentOptions options);
|
||||
void removeTable(UUID userId, UUID tableId);
|
||||
void removeTable(UUID tableId);
|
||||
TableView getTable(UUID tableId);
|
||||
Optional<TableView> getTable(UUID tableId);
|
||||
void leaveTable(UUID userId, UUID tableId);
|
||||
boolean watchTable(UUID userId, UUID tableId) throws MageException;
|
||||
|
||||
|
|
|
|||
|
|
@ -28,10 +28,7 @@
|
|||
package mage.server.game;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.concurrent.Executors;
|
||||
import java.util.concurrent.ScheduledExecutorService;
|
||||
|
|
@ -180,11 +177,11 @@ public class GamesRoomImpl extends RoomImpl implements GamesRoom, Serializable {
|
|||
}
|
||||
|
||||
@Override
|
||||
public TableView getTable(UUID tableId) {
|
||||
public Optional<TableView> getTable(UUID tableId) {
|
||||
if (tables.containsKey(tableId)) {
|
||||
return new TableView(tables.get(tableId));
|
||||
return Optional.of(new TableView(tables.get(tableId)));
|
||||
}
|
||||
return null;
|
||||
return Optional.empty();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -28,6 +28,7 @@
|
|||
|
||||
package mage.server.game;
|
||||
|
||||
import java.util.Optional;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
|
|
@ -57,8 +58,12 @@ public enum GamesRoomManager {
|
|||
return mainRoomId;
|
||||
}
|
||||
|
||||
public GamesRoom getRoom(UUID roomId) {
|
||||
return rooms.get(roomId);
|
||||
public Optional<GamesRoom> getRoom(UUID roomId) {
|
||||
if(rooms.containsKey(roomId)) {
|
||||
return Optional.of(rooms.get(roomId));
|
||||
}
|
||||
return Optional.empty();
|
||||
|
||||
}
|
||||
|
||||
public void removeTable(UUID tableId) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue