From 8c38fbb68a1b58cb01043e5d2912938b6d93c145 Mon Sep 17 00:00:00 2001 From: Bukkit/Spigot Date: Tue, 12 Jul 2022 21:32:00 +1000 Subject: [PATCH] #771: Throw IllegalAccessException with non-static getHandlerList Also add specifier for which event causes the issue By: Martoph --- .../main/java/org/bukkit/plugin/SimplePluginManager.java | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/paper-api/src/main/java/org/bukkit/plugin/SimplePluginManager.java b/paper-api/src/main/java/org/bukkit/plugin/SimplePluginManager.java index 5bec3c948b..1fe7249d3d 100644 --- a/paper-api/src/main/java/org/bukkit/plugin/SimplePluginManager.java +++ b/paper-api/src/main/java/org/bukkit/plugin/SimplePluginManager.java @@ -8,6 +8,7 @@ import com.google.common.graph.MutableGraph; import java.io.File; import java.lang.reflect.Constructor; import java.lang.reflect.Method; +import java.lang.reflect.Modifier; import java.util.ArrayList; import java.util.Collection; import java.util.HashMap; @@ -656,9 +657,14 @@ public final class SimplePluginManager implements PluginManager { try { Method method = getRegistrationClass(type).getDeclaredMethod("getHandlerList"); method.setAccessible(true); + + if (!Modifier.isStatic(method.getModifiers())) { + throw new IllegalAccessException("getHandlerList must be static"); + } + return (HandlerList) method.invoke(null); } catch (Exception e) { - throw new IllegalPluginAccessException(e.toString()); + throw new IllegalPluginAccessException("Error while registering listener for event type " + type.toString() + ": " + e.toString()); } }