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