Added a default to EventHandler.priority()

Fixed HandlerList.unregisterAll()
Fixed incorrect isAssignableFrom check in SimplePluginManager.getRegistrationClass()
This commit is contained in:
zml2008 2012-01-17 19:06:48 -08:00 committed by Erik Broes
parent 95e3f07b69
commit 81dc1c0a52
3 changed files with 5 additions and 3 deletions

View File

@ -11,5 +11,5 @@ public @interface EventHandler {
Class<? extends Event> event(); Class<? extends Event> event();
EventPriority priority(); EventPriority priority() default EventPriority.NORMAL;
} }

View File

@ -50,7 +50,9 @@ public class HandlerList {
public static void unregisterAll() { public static void unregisterAll() {
for (HandlerList h : alllists) { for (HandlerList h : alllists) {
h.handlerslots.clear(); for (List<RegisteredListener> list : h.handlerslots.values()) {
list.clear();
}
h.baked = false; h.baked = false;
} }
} }

View File

@ -471,7 +471,7 @@ public final class SimplePluginManager implements PluginManager {
} catch (NoSuchMethodException e) { } catch (NoSuchMethodException e) {
if (clazz.getSuperclass() != null if (clazz.getSuperclass() != null
&& !clazz.getSuperclass().equals(Event.class) && !clazz.getSuperclass().equals(Event.class)
&& clazz.getSuperclass().isAssignableFrom(Event.class)) { && Event.class.isAssignableFrom(clazz.getSuperclass())) {
return getRegistrationClass(clazz.getSuperclass().asSubclass(Event.class)); return getRegistrationClass(clazz.getSuperclass().asSubclass(Event.class));
} else { } else {
throw new IllegalPluginAccessException("Unable to find handler list for event " + clazz.getName()); throw new IllegalPluginAccessException("Unable to find handler list for event " + clazz.getName());