#762 - Move all sessions stuff to new SessionManager class

This commit is contained in:
Gnat008
2016-06-27 13:50:16 -04:00
parent 0c96a3113b
commit 1326606f37
7 changed files with 209 additions and 36 deletions
@@ -1,6 +1,7 @@
package fr.xephi.authme.process.quit;
import fr.xephi.authme.AuthMe;
import fr.xephi.authme.cache.SessionManager;
import fr.xephi.authme.cache.auth.PlayerAuth;
import fr.xephi.authme.cache.auth.PlayerCache;
import fr.xephi.authme.cache.limbo.LimboCache;
@@ -42,6 +43,9 @@ public class AsynchronousQuit implements AsynchronousProcess {
@Inject
private SyncProcessManager syncProcessManager;
@Inject
private SessionManager sessionManager;
AsynchronousQuit() { }
@@ -82,23 +86,21 @@ public class AsynchronousQuit implements AsynchronousProcess {
isOp = limbo.isOperator();
limboCache.deleteLimboPlayer(name);
}
if (Settings.isSessionsEnabled && !isKick) {
if (Settings.getSessionTimeout != 0) {
if (plugin.isEnabled()) {
BukkitTask task = plugin.getServer().getScheduler().runTaskLaterAsynchronously(plugin, new Runnable() {
if (!isKick) {
if (plugin.isEnabled()) {
BukkitTask task = plugin.getServer().getScheduler().runTaskLaterAsynchronously(plugin, new Runnable() {
@Override
public void run() {
postLogout(name);
}
@Override
public void run() {
postLogout(name);
}
}, Settings.getSessionTimeout * TICKS_PER_MINUTE);
}, Settings.getSessionTimeout * TICKS_PER_MINUTE);
plugin.getSessions().put(name, task);
} else {
//plugin is disabled; we cannot schedule more tasks so run it directly here
postLogout(name);
}
sessionManager.addSession(name, task);
} else {
//plugin is disabled; we cannot schedule more tasks so run it directly here
postLogout(name);
}
} else {
playerCache.removePlayer(name);
@@ -117,6 +119,6 @@ public class AsynchronousQuit implements AsynchronousProcess {
private void postLogout(String name) {
PlayerCache.getInstance().removePlayer(name);
database.setUnlogged(name);
plugin.getSessions().remove(name);
sessionManager.removeSession(name);
}
}