Add support for @OnClientCommand annotation to register and filter client command event handlers.

This commit is contained in:
Overlord committed 2026-10-07 13:09:27 +02:00
1 parent b4d70c3d3a
commit 1664bb6f28
6 files changed
+177 -24

No files matched your search

+10
View File
@@ -313,6 +313,16 @@ this.events().onMain(ClientCommandEvent.class, event ->
});
```
The same as an annotated listener method (see [Events](#events)), which filters and cancels:
```java
@OnClientCommand(module = "Shop", command = "buy", cancel = true) // command optional: every command of the module
void buy(ClientCommandEvent event) { ... }
```
`cancel = true` cancels the event before the method runs, so Lua does not receive the command
even when the method throws.
Server to client: `clientCommands().send(player, ...)` and `sendToAll(...)`; the Lua mod
receives them in `Events.OnServerCommand`.