package net.pterodactylus.util.event;
-import java.util.ArrayList;
import java.util.EventListener;
import java.util.List;
+import java.util.concurrent.CopyOnWriteArrayList;
/**
* Helper class for {@link EventListener} management.
* The type of the event listener
* @author David Roden <droden@gmail.com>
*/
-public class ListenerSupport<L extends EventListener> {
+public class ListenerManager<L extends EventListener> {
/** The list of registered listeners. */
- private final List<L> listeners = new ArrayList<L>();
+ private final List<L> listeners = new CopyOnWriteArrayList<L>();
/**
* Adds a listener to the list of registered listeners.
* @return The list of all listeners
*/
protected List<L> getListeners() {
- synchronized (listeners) {
- return new ArrayList<L>(listeners);
- }
+ return listeners;
}
}