forked from External/mage
Fixed some bugs in table handling. Fixed that matches were not set to finished yet, if players left match during sideboarding phase.
This commit is contained in:
parent
df9c200753
commit
40c25fae34
25 changed files with 274 additions and 140 deletions
|
|
@ -62,8 +62,8 @@ public class TableManager {
|
|||
private static final TableManager INSTANCE = new TableManager();
|
||||
private static final Logger logger = Logger.getLogger(TableManager.class);
|
||||
|
||||
private ConcurrentHashMap<UUID, TableController> controllers = new ConcurrentHashMap<UUID, TableController>();
|
||||
private ConcurrentHashMap<UUID, Table> tables = new ConcurrentHashMap<UUID, Table>();
|
||||
private final ConcurrentHashMap<UUID, TableController> controllers = new ConcurrentHashMap<UUID, TableController>();
|
||||
private final ConcurrentHashMap<UUID, Table> tables = new ConcurrentHashMap<UUID, Table>();
|
||||
|
||||
/**
|
||||
* Defines how often checking process should be run on server.
|
||||
|
|
@ -184,6 +184,7 @@ public class TableManager {
|
|||
|
||||
public boolean removeTable(UUID userId, UUID tableId) {
|
||||
if (isTableOwner(tableId, userId) || UserManager.getInstance().isAdmin(userId)) {
|
||||
leaveTable(userId, tableId);
|
||||
removeTable(tableId);
|
||||
return true;
|
||||
}
|
||||
|
|
@ -192,13 +193,14 @@ public class TableManager {
|
|||
|
||||
public void leaveTable(UUID userId, UUID tableId) {
|
||||
if (controllers.containsKey(tableId)) {
|
||||
controllers.get(tableId).leaveTable(userId);
|
||||
// table not started yet and user is the owner, remove the table
|
||||
if (isTableOwner(tableId, userId)) {
|
||||
if (getTable(tableId).getState().equals(TableState.WAITING)
|
||||
|| getTable(tableId).getState().equals(TableState.STARTING)) {
|
||||
removeTable(tableId);
|
||||
}
|
||||
if (isTableOwner(tableId, userId)
|
||||
&& (getTable(tableId).getState().equals(TableState.WAITING)
|
||||
|| getTable(tableId).getState().equals(TableState.STARTING))) {
|
||||
removeTable(tableId);
|
||||
|
||||
} else {
|
||||
controllers.get(tableId).leaveTable(userId);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue