Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 11 additions & 11 deletions src/content/docs/velocity/dev/api/event.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,18 +38,18 @@ The higher the priority, the earlier the event handler will be called.
State the desired order in the `@Subscribe` annotation:

```java
@Subscribe(priority = 0, order = PostOrder.CUSTOM)
@Subscribe(priority = 10)
public void onPlayerChatFirst(PlayerChatEvent event) {
// this method fires first
}

@Subscribe(priority = 5)
public void onPlayerChat(PlayerChatEvent event) {
// do stuff
// this method fires after the one above
}
```

`-32768` is the default value if you do not specify an order.
:::note

Due to compatibility constraints, you must specify [`PostOrder.CUSTOM`](jd:velocity:com.velocitypowered.api.event.PostOrder#CUSTOM) in order to use this field.

:::
`0` is the default value if you do not specify an order.

## Registering listeners

Expand Down Expand Up @@ -92,7 +92,7 @@ public class VelocityTest {

public class MyListener {

@Subscribe(order = PostOrder.EARLY)
@Subscribe
public void onPlayerChat(PlayerChatEvent event) {
// do something here
}
Expand Down Expand Up @@ -124,12 +124,12 @@ return an [`EventTask`](jd:velocity:com.velocitypowered.api.event.EventTask)
or add a second return an [`Continuation`](jd:velocity:com.velocitypowered.api.event.Continuation) parameter:

```java
@Subscribe(priority = 100, order = PostOrder.CUSTOM)
@Subscribe(priority = 100)
public void onLogin(LoginEvent event, Continuation continuation) {
doSomeAsyncProcessing().addListener(continuation::resume, continuation::resumeWithException);
}

@Subscribe(priority = 100, order = PostOrder.CUSTOM)
@Subscribe(priority = 100)
public EventTask onPlayerChat(PlayerChatEvent event) {
if (mustFurtherProcess(event)) {
return EventTask.async(() => ...);
Expand Down