/**
  * Register a new listener in this handler list
  *
  * @param listener listener to register
  */
 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;
   if (listener.getPriority() == EventPriority.EXECUTOR && allowExecutor == false) {
     throw new IllegalStateException("an executor is not allowed for this event");
   }
   if (listener.getPriority() == EventPriority.EXECUTOR
       && handlerslots.get(EventPriority.EXECUTOR).isEmpty() == false) {
     throw new IllegalStateException("an executor is already registered for this event");
   }
   handlerslots.get(listener.getPriority()).add(listener);
 }
 /**
  * Remove a listener from a specific order slot
  *
  * @param listener listener to remove
  */
 public synchronized void unregister(RegisteredListener listener) {
   if (handlerslots.get(listener.getPriority()).remove(listener)) {
     handlers = null;
   }
 }