mirror of
https://github.com/PaperMC/Paper.git
synced 2024-11-29 19:52:55 +01:00
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).
This commit is contained in:
parent
af964c8331
commit
f859d45727
1 changed files with 4 additions and 0 deletions
|
@ -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() {
|
||||
|
|
Loading…
Reference in a new issue