Add support for arbitrary event handler ordering.

This allows for 65,536 different orders, which should be more than enough for anyone.
This commit is contained in:
Andrew Steinborn
2020-10-22 01:02:40 -04:00
parent abfa05c249
commit 929d623be2
4 changed files with 13 additions and 9 deletions

View File

@@ -39,7 +39,7 @@ public interface EventManager {
* @param handler the handler to register
* @param <E> the event type to handle
*/
<E> void register(Object plugin, Class<E> eventClass, PostOrder postOrder,
<E> void register(Object plugin, Class<E> eventClass, short postOrder,
EventHandler<E> handler);
/**

View File

@@ -4,7 +4,12 @@ package com.velocitypowered.api.event;
* Represents the order an event will be posted to a listener method, relative to other listeners.
*/
public enum PostOrder {
;
FIRST, EARLY, NORMAL, LATE, LAST
public static final short FIRST = Short.MIN_VALUE;
public static final short EARLY = Short.MIN_VALUE >> 1;
public static final short NORMAL = 0;
public static final short LATE = Short.MAX_VALUE >> 1;
public static final short LAST = Short.MAX_VALUE;
}

View File

@@ -17,6 +17,6 @@ public @interface Subscribe {
*
* @return the order
*/
PostOrder order() default PostOrder.NORMAL;
short order() default PostOrder.NORMAL;
}