Plugins can no longer register events while disabled

By: Dinnerbone <dinnerbone@dinnerbone.com>
This commit is contained in:
Bukkit/Spigot
2011-03-14 15:11:43 +00:00
parent 7e9974d53c
commit 8117c7771d
2 changed files with 29 additions and 1 deletions

View File

@ -270,8 +270,9 @@ public final class SimplePluginManager implements PluginManager {
*/
public void registerEvent(Event.Type type, Listener listener, Priority priority, Plugin plugin) {
if (!plugin.isEnabled()) {
server.getLogger().warning("Plugin '" + plugin.getDescription().getName() + "' (ver " + plugin.getDescription().getVersion() + ") is registering events before it is enabled. It may be misbehaving and the author needs to fix this.");
throw new IllegalPluginAccessException("Plugin attempted to register " + type + " while not enabled");
}
getEventListeners( type ).add(new RegisteredListener(listener, priority, plugin, type));
}
@ -285,6 +286,10 @@ public final class SimplePluginManager implements PluginManager {
* @param plugin Plugin to register
*/
public void registerEvent(Event.Type type, Listener listener, EventExecutor executor, Priority priority, Plugin plugin) {
if (!plugin.isEnabled()) {
throw new IllegalPluginAccessException("Plugin attempted to register " + type + " while not enabled");
}
getEventListeners( type ).add(new RegisteredListener(listener, executor, priority, plugin));
}