Skip to content

Commit 48e45d0

Browse files
KastenKlickerpowercasgamerzlataovce
authored
fix: remove deprecated Velocity API usage (#504)
* Update event.mdx Update event.mdx to remove deprecated API usage * Update docs/velocity/dev/api/event.mdx Co-authored-by: powercas_gamer <[email protected]> * Update docs/velocity/dev/api/event.mdx Co-authored-by: powercas_gamer <[email protected]> * Update docs/velocity/dev/api/event.mdx Co-authored-by: Matouš Kučera <[email protected]> * Update docs/velocity/dev/api/event.mdx Co-authored-by: Matouš Kučera <[email protected]> * Update docs/velocity/dev/api/event.mdx Co-authored-by: Matouš Kučera <[email protected]> --------- Co-authored-by: powercas_gamer <[email protected]> Co-authored-by: Matouš Kučera <[email protected]>
1 parent 04a1f02 commit 48e45d0

File tree

1 file changed

+12
-7
lines changed

1 file changed

+12
-7
lines changed

docs/velocity/dev/api/event.mdx

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -33,20 +33,25 @@ and _not_ in `com.google.common.eventbus`.
3333

3434
## Orders
3535

36-
Every listener has a <Javadoc name={"com.velocitypowered.api.event.PostOrder"} project={"velocity"}>`PostOrder`</Javadoc>.
37-
When an event is fired, the order in which listeners are invoked is defined by their `PostOrder`.
38-
Listeners using `PostOrder.FIRST` are called first, then `EARLY`, `NORMAL`, etc.
36+
Every listener has a <Javadoc name={"com.velocitypowered.api.event.Subscribe#priority()"} project={"velocity"}>`priority`</Javadoc>.
37+
When an event is fired, the order in which listeners are invoked is defined by their `priority`.
38+
The higher the priority, the earlier the event handler will be called.
3939

4040
State the desired order in the `@Subscribe` annotation:
4141

4242
```java
43-
@Subscribe(order = PostOrder.NORMAL)
43+
@Subscribe(priority = 0, order = PostOrder.CUSTOM)
4444
public void onPlayerChat(PlayerChatEvent event) {
4545
// do stuff
4646
}
4747
```
4848

49-
`NORMAL` is the default value if you do not specify an order.
49+
`-32768` is the default value if you do not specify an order.
50+
:::note
51+
52+
Due to compatibility constraints, you must specify <Javadoc name={"com.velocitypowered.api.event.PostOrder#CUSTOM"} project={"velocity"}>`PostOrder.CUSTOM`</Javadoc> in order to use this field.
53+
54+
:::
5055

5156
## Registering listeners
5257

@@ -121,12 +126,12 @@ return an <Javadoc name={"com.velocitypowered.api.event.EventTask"} project={"ve
121126
or add a second return an <Javadoc name={"com.velocitypowered.api.event.Continuation"} project={"velocity"}>`Continuation`</Javadoc> parameter:
122127

123128
```java
124-
@Subscribe(order = PostOrder.EARLY)
129+
@Subscribe(priority = 100, order = PostOrder.CUSTOM)
125130
public void onLogin(LoginEvent event, Continuation continuation) {
126131
doSomeAsyncProcessing().addListener(continuation::resume, continuation::resumeWithException);
127132
}
128133

129-
@Subscribe(order = PostOrder.EARLY)
134+
@Subscribe(priority = 100, order = PostOrder.CUSTOM)
130135
public EventTask onPlayerChat(PlayerChatEvent event) {
131136
if (mustFurtherProcess(event)) {
132137
return EventTask.async(() => ...);

0 commit comments

Comments
 (0)