Fix nonsensical deprecation for specifying listener priority (#1491)

* Fix nonsensical deprecation for specifying listener priority

* Fix checkstyle error
This commit is contained in:
Henri Schubin
2025-01-21 19:37:20 +02:00
committed by GitHub
parent 71feb11b2e
commit 7392cd6574
3 changed files with 12 additions and 6 deletions

View File

@@ -12,6 +12,14 @@ package com.velocitypowered.api.event;
*/ */
public enum PostOrder { 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
} }

View File

@@ -32,12 +32,9 @@ public @interface Subscribe {
* The priority of this event handler. Priorities are used to determine the order in which event * 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. * 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 * @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 * Whether the handler must be called asynchronously. By default, all event handlers are called

View File

@@ -350,8 +350,9 @@ public class VelocityEventManager implements EventManager {
asyncType = AsyncType.ALWAYS; asyncType = AsyncType.ALWAYS;
} }
// The default value of 0 will fall back to PostOrder, the default PostOrder (NORMAL) is also 0
final short order; final short order;
if (subscribe.order() == PostOrder.CUSTOM) { if (subscribe.priority() != 0) {
order = subscribe.priority(); order = subscribe.priority();
} else { } else {
order = (short) POST_ORDER_MAP.get(subscribe.order()); order = (short) POST_ORDER_MAP.get(subscribe.order());