data-driven event system
1# Events
2
3Events in Commander are points during gameplay when your [commands](Commands) will be invoked.
4
5## Introduction to subscriptions
6
7An event declaration in your subscription file is an identifier of the event you want to subscribe to. An event can accept additional parameters in the `parameters` block, but built-in events do not require them (yet). Subscription files are read from `commander/events`.
8
9```
10|- recipes
11|- commander
12 |- events
13 |- test_event.json
14 |- folder
15 |- nested.json
16|- tags
17```
18
19A typical event declaration might look something like this:
20
21::: details Example
22```json
23{
24 "event": "commander:after_killed_by_other",
25 "commands": [
26
27 ]
28}
29```
30<br/>
31
32```json
33{
34 "event": "modid:custom_event",
35 "parameters": {
36 },
37 "commands": [
38
39 ]
40}
41```
42:::
43
44The subscription file can contain multiple subscriptions to different (or identical) events.
45
46::: details Example
47```json
48{
49 "events": [
50 {
51 "event": "commander:after_killed_by_other"
52 },
53 {
54 "event": "commander:allow_damage"
55 },
56 {
57 "event": "commander:player_attack/block"
58 }
59 ]
60}
61```
62:::
63
64## Built-in events
65
66Commander wraps most compatible fabric events under the `commander` namespace. "Return" here means the [cancel command](Commands#commandercancel)
67
68Currently available events can be seen here: [EntityEvents](https://github.com/constellation-mc/commander/blob/main/src/main/java/me/melontini/commander/impl/builtin/events/EntityEvents.java), [PlayerEvents](https://github.com/constellation-mc/commander/blob/main/src/main/java/me/melontini/commander/impl/builtin/events/PlayerEvents.java), [ServerLifecycle](https://github.com/constellation-mc/commander/blob/main/src/main/java/me/melontini/commander/impl/builtin/events/ServerLifecycle.java), [ServerTick](https://github.com/constellation-mc/commander/blob/main/src/main/java/me/melontini/commander/impl/builtin/events/ServerTick.java)