[Fix] Prevented session save from server thread

Affected issues: #748
This commit is contained in:
Rsl1122 2018-10-14 22:07:16 +03:00
parent b5c29a1c0d
commit 72f0937524
2 changed files with 3 additions and 8 deletions

View File

@ -128,10 +128,9 @@ public class PlayerOnlineListener implements Listener {
String playerName = player.getName(); String playerName = player.getName();
String displayName = player.getDisplayName(); String displayName = player.getDisplayName();
sessionCache.cacheSession(uuid, new Session(uuid, serverInfo.getServerUUID(), time, world, gm));
boolean gatheringGeolocations = config.isTrue(Settings.DATA_GEOLOCATIONS); boolean gatheringGeolocations = config.isTrue(Settings.DATA_GEOLOCATIONS);
processing.submitCritical(() -> sessionCache.cacheSession(uuid, new Session(uuid, serverInfo.getServerUUID(), time, world, gm)));
runnableFactory.create("Player Register: " + uuid, runnableFactory.create("Player Register: " + uuid,
processors.player().registerProcessor(uuid, player::getFirstPlayed, playerName, processors.player().registerProcessor(uuid, player::getFirstPlayed, playerName,
gatheringGeolocations ? processors.player().ipUpdateProcessor(uuid, address, time) : null, gatheringGeolocations ? processors.player().ipUpdateProcessor(uuid, address, time) : null,

View File

@ -118,20 +118,16 @@ public class SpongePlayerListener {
String world = player.getWorld().getName(); String world = player.getWorld().getName();
Optional<GameMode> gameMode = player.getGameModeData().get(Keys.GAME_MODE); Optional<GameMode> gameMode = player.getGameModeData().get(Keys.GAME_MODE);
String gm = "ADVENTURE"; String gm = gameMode.map(mode -> mode.getName().toUpperCase()).orElse("ADVENTURE");
if (gameMode.isPresent()) {
gm = gameMode.get().getName().toUpperCase();
}
InetAddress address = player.getConnection().getAddress().getAddress(); InetAddress address = player.getConnection().getAddress().getAddress();
String playerName = player.getName(); String playerName = player.getName();
String displayName = player.getDisplayNameData().displayName().get().toPlain(); String displayName = player.getDisplayNameData().displayName().get().toPlain();
sessionCache.cacheSession(uuid, new Session(uuid, serverInfo.getServerUUID(), time, world, gm));
boolean gatheringGeolocations = config.isTrue(Settings.DATA_GEOLOCATIONS); boolean gatheringGeolocations = config.isTrue(Settings.DATA_GEOLOCATIONS);
processing.submitCritical(() -> sessionCache.cacheSession(uuid, new Session(uuid, serverInfo.getServerUUID(), time, world, gm)));
runnableFactory.create("Player Register: " + uuid, runnableFactory.create("Player Register: " + uuid,
processors.player().registerProcessor(uuid, () -> time, playerName, processors.player().registerProcessor(uuid, () -> time, playerName,
gatheringGeolocations ? processors.player().ipUpdateProcessor(uuid, address, time) : null, gatheringGeolocations ? processors.player().ipUpdateProcessor(uuid, address, time) : null,