From 678891d0b82541da8f49e34d1e50271f4e454f65 Mon Sep 17 00:00:00 2001 From: games647 Date: Tue, 26 Jan 2016 21:30:11 +0100 Subject: [PATCH] Don't schedule more tasks if the plugin is disabled (Fixes Xephi/AuthMeReloaded#433) --- .../authme/process/quit/AsynchronousQuit.java | 34 +++++++++++++------ 1 file changed, 23 insertions(+), 11 deletions(-) diff --git a/src/main/java/fr/xephi/authme/process/quit/AsynchronousQuit.java b/src/main/java/fr/xephi/authme/process/quit/AsynchronousQuit.java index 80dd49b99..00b477440 100644 --- a/src/main/java/fr/xephi/authme/process/quit/AsynchronousQuit.java +++ b/src/main/java/fr/xephi/authme/process/quit/AsynchronousQuit.java @@ -75,18 +75,21 @@ public class AsynchronousQuit { } if (Settings.isSessionsEnabled && !isKick) { 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 - public void run() { - PlayerCache.getInstance().removePlayer(name); - if (database.isLogged(name)) - database.setUnlogged(name); - plugin.sessions.remove(name); - } + @Override + public void run() { + postLogout(); + } - }, Settings.getSessionTimeout * 20 * 60); - plugin.sessions.put(name, task); + }, 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); - 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); } }