diff options
author | Wesley Wolfe <weswolf@aol.com> | 2012-08-25 17:48:53 -0500 |
---|---|---|
committer | Wesley Wolfe <weswolf@aol.com> | 2012-08-25 17:48:53 -0500 |
commit | e04c1c2a1848a156f279ab913347a51fba3781d1 (patch) | |
tree | 5cf7f6969b268fb449a3b474c7a9f4d1e339f428 | |
parent | b4cb6c2eeae792fab98a8782781257539662ed38 (diff) | |
download | bukkit-e04c1c2a1848a156f279ab913347a51fba3781d1.tar bukkit-e04c1c2a1848a156f279ab913347a51fba3781d1.tar.gz bukkit-e04c1c2a1848a156f279ab913347a51fba3781d1.tar.lz bukkit-e04c1c2a1848a156f279ab913347a51fba3781d1.tar.xz bukkit-e04c1c2a1848a156f279ab913347a51fba3781d1.zip |
Provide better verbose for registering listeners. Addresses BUKKIT-2391
-rw-r--r-- | src/main/java/org/bukkit/plugin/java/JavaPluginLoader.java | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/src/main/java/org/bukkit/plugin/java/JavaPluginLoader.java b/src/main/java/org/bukkit/plugin/java/JavaPluginLoader.java index cf54ba84..c82f731c 100644 --- a/src/main/java/org/bukkit/plugin/java/JavaPluginLoader.java +++ b/src/main/java/org/bukkit/plugin/java/JavaPluginLoader.java @@ -21,7 +21,6 @@ import java.util.logging.Level; import java.util.regex.Pattern; import org.apache.commons.lang.Validate; -import org.bukkit.Bukkit; import org.bukkit.Server; import org.bukkit.Warning; import org.bukkit.Warning.WarningState; @@ -272,22 +271,26 @@ public class JavaPluginLoader implements PluginLoader { } public Map<Class<? extends Event>, Set<RegisteredListener>> createRegisteredListeners(Listener listener, final Plugin plugin) { + Validate.notNull(plugin, "Plugin can not be null"); + Validate.notNull(listener, "Listener can not be null"); + boolean useTimings = server.getPluginManager().useTimings(); Map<Class<? extends Event>, Set<RegisteredListener>> ret = new HashMap<Class<? extends Event>, Set<RegisteredListener>>(); Method[] methods; try { methods = listener.getClass().getDeclaredMethods(); } catch (NoClassDefFoundError e) { - Bukkit.getServer().getLogger().severe("Plugin " + plugin.getDescription().getName() + " is attempting to register event " + e.getMessage() + ", which does not exist. Ignoring events registered in " + listener.getClass()); + plugin.getLogger().severe("Plugin " + plugin.getDescription().getFullName() + " has failed to register events for " + listener.getClass() + " because " + e.getMessage() + " does not exist."); return ret; } + for (int i = 0; i < methods.length; i++) { final Method method = methods[i]; final EventHandler eh = method.getAnnotation(EventHandler.class); if (eh == null) continue; final Class<?> checkClass = method.getParameterTypes()[0]; if (!Event.class.isAssignableFrom(checkClass) || method.getParameterTypes().length != 1) { - plugin.getServer().getLogger().severe("Wrong method arguments used for event type registered"); + plugin.getLogger().severe(plugin.getDescription().getFullName() + " attempted to register an invalid EventHandler method signature \"" + method.toGenericString() + "\" in " + listener.getClass()); continue; } final Class<? extends Event> eventClass = checkClass.asSubclass(Event.class); |