From f859d457271dd941b99568ec144b626e65ae25b2 Mon Sep 17 00:00:00 2001 From: Wesley Wolfe Date: Sun, 31 Mar 2013 15:37:17 -0500 Subject: [PATCH] Throw exception for disabled plugin tasks. Fixes BUKKIT-3951 Without this check, any non-null reference to a plugin is considered 'valid' for registering a task in the scheduler. This is obviously unintentional behavior and has been changed to throw an IllegalPluginAccessException. It is now consistent with the SimplePluginManager event registration contract. This in affect also addresses BUKKIT-3950 for uninitialized plugin references (ones without a description). --- .../java/org/bukkit/craftbukkit/scheduler/CraftScheduler.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/main/java/org/bukkit/craftbukkit/scheduler/CraftScheduler.java b/src/main/java/org/bukkit/craftbukkit/scheduler/CraftScheduler.java index 0a5c61a89c..84dcfccae5 100644 --- a/src/main/java/org/bukkit/craftbukkit/scheduler/CraftScheduler.java +++ b/src/main/java/org/bukkit/craftbukkit/scheduler/CraftScheduler.java @@ -15,6 +15,7 @@ import java.util.concurrent.atomic.AtomicReference; import java.util.logging.Level; import org.apache.commons.lang.Validate; +import org.bukkit.plugin.IllegalPluginAccessException; import org.bukkit.plugin.Plugin; import org.bukkit.scheduler.BukkitScheduler; import org.bukkit.scheduler.BukkitTask; @@ -389,6 +390,9 @@ public class CraftScheduler implements BukkitScheduler { private static void validate(final Plugin plugin, final Object task) { Validate.notNull(plugin, "Plugin cannot be null"); Validate.notNull(task, "Task cannot be null"); + if (!plugin.isEnabled()) { + throw new IllegalPluginAccessException("Plugin attempted to register task while disabled"); + } } private int nextId() {