mirror of
https://github.com/correl/mage.git
synced 2024-11-28 19:19:55 +00:00
* Some minor reworks to prevent exceptions.
This commit is contained in:
parent
2efc666f8d
commit
fbd90bb3e0
1 changed files with 14 additions and 16 deletions
|
@ -27,6 +27,10 @@
|
||||||
*/
|
*/
|
||||||
package mage.server;
|
package mage.server;
|
||||||
|
|
||||||
|
import java.util.*;
|
||||||
|
import java.util.Map.Entry;
|
||||||
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
|
import java.util.concurrent.TimeUnit;
|
||||||
import mage.cards.decks.Deck;
|
import mage.cards.decks.Deck;
|
||||||
import mage.constants.ManaType;
|
import mage.constants.ManaType;
|
||||||
import mage.constants.TableState;
|
import mage.constants.TableState;
|
||||||
|
@ -51,11 +55,6 @@ import mage.server.util.SystemUtil;
|
||||||
import mage.view.TableClientMessage;
|
import mage.view.TableClientMessage;
|
||||||
import org.apache.log4j.Logger;
|
import org.apache.log4j.Logger;
|
||||||
|
|
||||||
import java.util.*;
|
|
||||||
import java.util.Map.Entry;
|
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
|
||||||
import java.util.concurrent.TimeUnit;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author BetaSteward_at_googlemail.com
|
* @author BetaSteward_at_googlemail.com
|
||||||
*/
|
*/
|
||||||
|
@ -242,8 +241,8 @@ public class User {
|
||||||
|
|
||||||
public void fireCallback(final ClientCallback call) {
|
public void fireCallback(final ClientCallback call) {
|
||||||
if (isConnected()) {
|
if (isConnected()) {
|
||||||
SessionManager.instance.getSession(sessionId).ifPresent(session ->
|
SessionManager.instance.getSession(sessionId).ifPresent(session
|
||||||
session.fireCallback(call)
|
-> session.fireCallback(call)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -380,8 +379,7 @@ public class User {
|
||||||
Optional<TableController> controller = TableManager.instance.getController(entry.getKey());
|
Optional<TableController> controller = TableManager.instance.getController(entry.getKey());
|
||||||
if (controller.isPresent()) {
|
if (controller.isPresent()) {
|
||||||
ccSideboard(entry.getValue(), entry.getKey(), controller.get().getRemainingTime(), controller.get().getOptions().isLimited());
|
ccSideboard(entry.getValue(), entry.getKey(), controller.get().getRemainingTime(), controller.get().getOptions().isLimited());
|
||||||
}
|
} else {
|
||||||
else{
|
|
||||||
logger.error("sideboarding id not found : " + entry.getKey());
|
logger.error("sideboarding id not found : " + entry.getKey());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -458,7 +456,8 @@ public class User {
|
||||||
}
|
}
|
||||||
gameSessions.clear();
|
gameSessions.clear();
|
||||||
logger.trace("REMOVE " + userName + " watched Games " + watchedGames.size());
|
logger.trace("REMOVE " + userName + " watched Games " + watchedGames.size());
|
||||||
for (UUID gameId : watchedGames) {
|
for (Iterator<UUID> it = watchedGames.iterator(); it.hasNext();) { // Iterator to prevent ConcurrentModificationException
|
||||||
|
UUID gameId = it.next();
|
||||||
GameManager.instance.stopWatching(gameId, userId);
|
GameManager.instance.stopWatching(gameId, userId);
|
||||||
}
|
}
|
||||||
watchedGames.clear();
|
watchedGames.clear();
|
||||||
|
@ -791,8 +790,7 @@ public class User {
|
||||||
Optional<TableController> tableController = TableManager.instance.getController(table.getId());
|
Optional<TableController> tableController = TableManager.instance.getController(table.getId());
|
||||||
if (!tableController.isPresent()) {
|
if (!tableController.isPresent()) {
|
||||||
logger.error("table not found : " + table.getId());
|
logger.error("table not found : " + table.getId());
|
||||||
}
|
} else if (tableController.get().isUserStillActive(userId)) {
|
||||||
else if (tableController.get().isUserStillActive(userId)) {
|
|
||||||
number++;
|
number++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue