Skip to content

Commit

Permalink
Fix nonsensical deprecation for specifying listener priority (#1491)
Browse files Browse the repository at this point in the history
* Fix nonsensical deprecation for specifying listener priority

* Fix checkstyle error
  • Loading branch information
Vankka authored Jan 21, 2025
1 parent 71feb11 commit 7392cd6
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 6 deletions.
10 changes: 9 additions & 1 deletion api/src/main/java/com/velocitypowered/api/event/PostOrder.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,14 @@
*/
public enum PostOrder {

FIRST, EARLY, NORMAL, LATE, LAST, CUSTOM
FIRST, EARLY, NORMAL, LATE, LAST,

/**
* Previously used to specify that {@link Subscribe#priority()} should be used.
*
* @deprecated No longer required, you only need to specify {@link Subscribe#priority()}.
*/
@Deprecated
CUSTOM

}
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,9 @@
* The priority of this event handler. Priorities are used to determine the order in which event
* handlers are called. The higher the priority, the earlier the event handler will be called.
*
* <p>Note that due to compatibility constraints, you must specify {@link PostOrder#CUSTOM}
* in order to use this field.</p>
*
* @return the priority
*/
short priority() default Short.MIN_VALUE;
short priority() default 0;

/**
* Whether the handler must be called asynchronously. By default, all event handlers are called
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -350,8 +350,9 @@ private void collectMethods(final Class<?> targetClass,
asyncType = AsyncType.ALWAYS;
}

// The default value of 0 will fall back to PostOrder, the default PostOrder (NORMAL) is also 0
final short order;
if (subscribe.order() == PostOrder.CUSTOM) {
if (subscribe.priority() != 0) {
order = subscribe.priority();
} else {
order = (short) POST_ORDER_MAP.get(subscribe.order());
Expand Down

0 comments on commit 7392cd6

Please sign in to comment.