 +
 +    private boolean hasRegistrations(EventPriority priority) {
 +        ArrayList<RegisteredListener> registered = handlerslots.get(priority);
-+        return registered != null && registered.size() > 0;
++        return registered.size() > 0;
 +    }
 +
 +    private void add(RegisteredListener listener) {

                     changed = true;
                 }
             }
@@ -228,4 +235,53 @@ public class HandlerList {
             return (ArrayList<HandlerList>) allLists.clone();
         }
     }
+
+    public Iterable<RegisteredListener> getRegisteredListeners(EventPriority priority) {
+        ArrayList<RegisteredListener> listeners = handlerslots.get(priority);
+        return listeners != null ? listeners : Collections.<RegisteredListener>emptyList();
+    }
+
+    private List<Adapter> adapter = new ArrayList<Adapter>();

From eed60834841859777a95ef7053c395756c242015 Mon Sep 17 00:00:00 2001
From: Minecrell <dev@minecrell.net>
Date: Sat, 31 Jan 2015 19:28:20 +0100
Subject: [PATCH] Add HandlerList adapters


diff --git a/src/main/java/org/bukkit/event/HandlerList.java b/src/main/java/org/bukkit/event/HandlerList.java
index 7d5efff..b5d78df 100644
--- a/src/main/java/org/bukkit/event/HandlerList.java
+++ b/src/main/java/org/bukkit/event/HandlerList.java
@@ -52,7 +52,8 @@ public class HandlerList {
                     for (List<RegisteredListener> list : h.handlerslots.values()) {
                         list.clear();
                     }
-                    h.handlers = null;
+                    h.reset();
+                    h.removeAll();
                 }
             }
         }
@@ -107,7 +108,8 @@ public class HandlerList {
     public synchronized void register(RegisteredListener listener) {
         if (handlerslots.get(listener.getPriority()).contains(listener))
             throw new IllegalStateException("This listener is already registered to priority " + listener.getPriority().toString());
-        handlers = null;
+        reset();
+        add(listener);
         handlerslots.get(listener.getPriority()).add(listener);
     }
 
@@ -129,7 +131,8 @@ public class HandlerList {
      */
     public synchronized void unregister(RegisteredListener listener) {
         if (handlerslots.get(listener.getPriority()).remove(listener)) {
-            handlers = null;
+            reset();
+            remove(listener);
         }
     }
 
@@ -142,13 +145,15 @@ public class HandlerList {
         boolean changed = false;
         for (List<RegisteredListener> list : handlerslots.values()) {
             for (ListIterator<RegisteredListener> i = list.listIterator(); i.hasNext();) {
