forked from External/mage
[app-wiring-refactor]: Apply review comments:
- Add reference to original library in `FluentBuilder`. - Change `I<Name>` notation to `<Name>Impl` notation. - Move error config to test resources - Add comment with config instruction - Add config to the documentation
This commit is contained in:
parent
e8bb8ae24b
commit
6e3750d50a
41 changed files with 171 additions and 146 deletions
|
|
@ -1,68 +0,0 @@
|
|||
package mage.server.game;
|
||||
|
||||
import mage.server.managers.IGamesRoomManager;
|
||||
import mage.server.managers.ManagerFactory;
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
import java.util.Optional;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
/**
|
||||
* @author BetaSteward_at_googlemail.com
|
||||
*/
|
||||
public class GamesRoomManager implements IGamesRoomManager {
|
||||
|
||||
private final ManagerFactory managerFactory;
|
||||
private final ConcurrentHashMap<UUID, GamesRoom> rooms = new ConcurrentHashMap<>();
|
||||
private UUID mainRoomId;
|
||||
private UUID mainChatId;
|
||||
private static final Logger logger = Logger.getLogger(GamesRoomManager.class);
|
||||
|
||||
|
||||
public GamesRoomManager(ManagerFactory managerFactory) {
|
||||
this.managerFactory = managerFactory;
|
||||
}
|
||||
|
||||
public void init() {
|
||||
GamesRoom mainRoom = new GamesRoomImpl(managerFactory);
|
||||
mainRoomId = mainRoom.getRoomId();
|
||||
mainChatId = mainRoom.getChatId();
|
||||
rooms.put(mainRoomId, mainRoom);
|
||||
}
|
||||
|
||||
@Override
|
||||
public UUID createRoom() {
|
||||
GamesRoom room = new GamesRoomImpl(managerFactory);
|
||||
rooms.put(room.getRoomId(), room);
|
||||
return room.getRoomId();
|
||||
}
|
||||
|
||||
@Override
|
||||
public UUID getMainRoomId() {
|
||||
return mainRoomId;
|
||||
}
|
||||
|
||||
@Override
|
||||
public UUID getMainChatId() {
|
||||
return mainChatId;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Optional<GamesRoom> getRoom(UUID roomId) {
|
||||
if (rooms.containsKey(roomId)) {
|
||||
return Optional.of(rooms.get(roomId));
|
||||
}
|
||||
logger.warn("room not found : " + roomId); // after server restart users try to use old rooms on reconnect
|
||||
return Optional.empty();
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeTable(UUID tableId) {
|
||||
for (GamesRoom room : rooms.values()) {
|
||||
room.removeTable(tableId);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue