setListenerOrder(listener, eventClass, true);
}
private static void setListenerOrder(Listener listener, Class<?> eventClass, boolean first) {
HandlerList list = getEventHandlerList(eventClass);
final EventPriority prio = first ? EventPriority.LOWEST : EventPriority.MONITOR;
synchronized (list) {
EnumMap<EventPriority, ArrayList<RegisteredListener>> handlerSlots = SafeField.get(list, "handlerslots");
ArrayList<RegisteredListener> registeredListenerList = handlerSlots.get(prio);
int requestedIndex = first ? 0 : (registeredListenerList.size() - 1);