Refactor sessions a bit to fix #419

This commit is contained in:
games647
2016-06-28 16:03:04 +02:00
parent 874869cef8
commit 469e8d3a48
3 changed files with 21 additions and 23 deletions
@@ -86,27 +86,29 @@ public class AsynchronousQuit implements AsynchronousProcess {
isOp = limbo.isOperator();
limboCache.deleteLimboPlayer(name);
}
if (!isKick) {
if (plugin.isEnabled()) {
BukkitTask task = plugin.getServer().getScheduler().runTaskLaterAsynchronously(plugin, new Runnable() {
@Override
public void run() {
postLogout(name);
}
//always unauthenticate the player - use session only for auto logins on the same ip
playerCache.removePlayer(name);
}, Settings.getSessionTimeout * TICKS_PER_MINUTE);
if (plugin.isEnabled() && Settings.isSessionsEnabled) {
BukkitTask task = plugin.getServer().getScheduler().runTaskLaterAsynchronously(plugin, new Runnable() {
sessionManager.addSession(name, task);
} else {
//plugin is disabled; we cannot schedule more tasks so run it directly here
postLogout(name);
}
@Override
public void run() {
postLogout(name);
}
}, Settings.getSessionTimeout * TICKS_PER_MINUTE);
sessionManager.addSession(name, task);
} else {
playerCache.removePlayer(name);
database.setUnlogged(name);
//plugin is disabled; we cannot schedule more tasks so run it directly here
postLogout(name);
}
//always update the database when the player quit the game
database.setUnlogged(name);
if (plugin.isEnabled()) {
syncProcessManager.processSyncPlayerQuit(player, isOp, needToChange);
}
@@ -117,8 +119,6 @@ public class AsynchronousQuit implements AsynchronousProcess {
}
private void postLogout(String name) {
PlayerCache.getInstance().removePlayer(name);
database.setUnlogged(name);
sessionManager.removeSession(name);
}
}