SPIGOT-893: Fix bridge method registering generic listeners twice

By: Jonas Konrad <me@yawk.at>
This commit is contained in:
Bukkit/Spigot
2015-05-18 11:14:47 +02:00
parent fa63b3d7f4
commit 745401c988
2 changed files with 54 additions and 0 deletions

View File

@@ -250,6 +250,11 @@ public final class JavaPluginLoader implements PluginLoader {
for (final Method method : methods) {
final EventHandler eh = method.getAnnotation(EventHandler.class);
if (eh == null) continue;
// Do not register bridge or synthetic methods to avoid event duplication
// Fixes SPIGOT-893
if (method.isBridge() || method.isSynthetic()) {
continue;
}
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());