Don't schedule more tasks if the plugin is disabled

(Fixes Xephi/AuthMeReloaded#433)
This commit is contained in:
games647 2016-01-26 21:30:11 +01:00
parent a3f1084fd8
commit 678891d0b8

View File

@ -75,18 +75,21 @@ public class AsynchronousQuit {
}
if (Settings.isSessionsEnabled && !isKick) {
if (Settings.getSessionTimeout != 0) {
if (plugin.isEnabled()) {
BukkitTask task = plugin.getServer().getScheduler().runTaskLaterAsynchronously(plugin, new Runnable() {
@Override
public void run() {
PlayerCache.getInstance().removePlayer(name);
if (database.isLogged(name))
database.setUnlogged(name);
plugin.sessions.remove(name);
postLogout();
}
}, Settings.getSessionTimeout * 20 * 60);
plugin.sessions.put(name, task);
} else {
//plugin is disable we canno schedule more tasks so run it directly here
postLogout();
}
}
} else {
PlayerCache.getInstance().removePlayer(name);
@ -94,6 +97,15 @@ public class AsynchronousQuit {
}
plugin.realIp.remove(name);
if (plugin.isEnabled()) {
Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, new ProcessSyncronousPlayerQuit(plugin, player, isOp, needToChange));
}
}
private void postLogout() {
PlayerCache.getInstance().removePlayer(name);
if (database.isLogged(name))
database.setUnlogged(name);
plugin.sessions.remove(name);
}
}