From 50f297d941fc0891384c5b2b4718f4797ee2827e Mon Sep 17 00:00:00 2001 From: Bukkit/Spigot Date: Sat, 16 Mar 2013 17:17:09 -0500 Subject: [PATCH] Validate method parameters when registering events. Fixes BUKKIT-3779 By: feildmaster --- .../main/java/org/bukkit/plugin/java/JavaPluginLoader.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/paper-api/src/main/java/org/bukkit/plugin/java/JavaPluginLoader.java b/paper-api/src/main/java/org/bukkit/plugin/java/JavaPluginLoader.java index 10fc26aed1..ea30d83d5f 100644 --- a/paper-api/src/main/java/org/bukkit/plugin/java/JavaPluginLoader.java +++ b/paper-api/src/main/java/org/bukkit/plugin/java/JavaPluginLoader.java @@ -380,8 +380,8 @@ public class JavaPluginLoader implements PluginLoader { for (final Method method : methods) { 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) { + final Class checkClass; + if (method.getParameterTypes().length != 1 || !Event.class.isAssignableFrom(checkClass = method.getParameterTypes()[0])) { plugin.getLogger().severe(plugin.getDescription().getFullName() + " attempted to register an invalid EventHandler method signature \"" + method.toGenericString() + "\" in " + listener.getClass()); continue; }