mirror of
https://github.com/PaperMC/Paper.git
synced 2025-08-07 23:52:11 -07:00
#771: Throw IllegalAccessException with non-static getHandlerList
Also add specifier for which event causes the issue By: Martoph <sager1018@gmail.com>
This commit is contained in:
@@ -8,6 +8,7 @@ import com.google.common.graph.MutableGraph;
|
|||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.lang.reflect.Constructor;
|
import java.lang.reflect.Constructor;
|
||||||
import java.lang.reflect.Method;
|
import java.lang.reflect.Method;
|
||||||
|
import java.lang.reflect.Modifier;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
@@ -656,9 +657,14 @@ public final class SimplePluginManager implements PluginManager {
|
|||||||
try {
|
try {
|
||||||
Method method = getRegistrationClass(type).getDeclaredMethod("getHandlerList");
|
Method method = getRegistrationClass(type).getDeclaredMethod("getHandlerList");
|
||||||
method.setAccessible(true);
|
method.setAccessible(true);
|
||||||
|
|
||||||
|
if (!Modifier.isStatic(method.getModifiers())) {
|
||||||
|
throw new IllegalAccessException("getHandlerList must be static");
|
||||||
|
}
|
||||||
|
|
||||||
return (HandlerList) method.invoke(null);
|
return (HandlerList) method.invoke(null);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
throw new IllegalPluginAccessException(e.toString());
|
throw new IllegalPluginAccessException("Error while registering listener for event type " + type.toString() + ": " + e.toString());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user