diff options
author | Dinnerbone <dinnerbone@dinnerbone.com> | 2011-03-14 15:11:43 +0000 |
---|---|---|
committer | Dinnerbone <dinnerbone@dinnerbone.com> | 2011-03-14 15:11:43 +0000 |
commit | 6f9b8479c658a3696a7d2cb9840da9a51e2fb1cb (patch) | |
tree | d2daa69bee0205e07a2559969b4453cac23c4698 /src/main/java | |
parent | 7867b27965441a3c9cf1b4a86b9108c434819a76 (diff) | |
download | bukkit-6f9b8479c658a3696a7d2cb9840da9a51e2fb1cb.tar bukkit-6f9b8479c658a3696a7d2cb9840da9a51e2fb1cb.tar.gz bukkit-6f9b8479c658a3696a7d2cb9840da9a51e2fb1cb.tar.lz bukkit-6f9b8479c658a3696a7d2cb9840da9a51e2fb1cb.tar.xz bukkit-6f9b8479c658a3696a7d2cb9840da9a51e2fb1cb.zip |
Plugins can no longer register events while disabled
Diffstat (limited to 'src/main/java')
-rw-r--r-- | src/main/java/org/bukkit/plugin/IllegalPluginAccessException.java | 23 | ||||
-rw-r--r-- | src/main/java/org/bukkit/plugin/SimplePluginManager.java | 7 |
2 files changed, 29 insertions, 1 deletions
diff --git a/src/main/java/org/bukkit/plugin/IllegalPluginAccessException.java b/src/main/java/org/bukkit/plugin/IllegalPluginAccessException.java new file mode 100644 index 00000000..e438d09d --- /dev/null +++ b/src/main/java/org/bukkit/plugin/IllegalPluginAccessException.java @@ -0,0 +1,23 @@ + +package org.bukkit.plugin; + +/** + * Thrown when a plugin attempts to interact with the server when it is not enabled + */ +public class IllegalPluginAccessException extends RuntimeException { + + /** + * Creates a new instance of <code>IllegalPluginAccessException</code> without detail message. + */ + public IllegalPluginAccessException() { + } + + + /** + * Constructs an instance of <code>IllegalPluginAccessException</code> with the specified detail message. + * @param msg the detail message. + */ + public IllegalPluginAccessException(String msg) { + super(msg); + } +} diff --git a/src/main/java/org/bukkit/plugin/SimplePluginManager.java b/src/main/java/org/bukkit/plugin/SimplePluginManager.java index 4bb73957..66f008aa 100644 --- a/src/main/java/org/bukkit/plugin/SimplePluginManager.java +++ b/src/main/java/org/bukkit/plugin/SimplePluginManager.java @@ -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)); } |