Go: Events¶
Functions¶
Subscribe¶
| Go | |
|---|---|
Subscribe calls fn for every event with this id, on the server thread. The id is the full one, such as "ll::event::PlayerJoinEvent", or a unique suffix of it. Server thread only.
- Parameters:
- id :
string - priority :
Priority - fn :
func(*Event)
- id :
- Return type:
(*Listener, error) - Slots:
subscribe_event
ListEvents¶
| Go | |
|---|---|
ListEvents lists every event id this host can subscribe to. Server thread only.
- Return type:
([]string, error) - Slots:
list_events
Event¶
Event is one event as a listener receives it. SNBT is the payload, whose fields the event payload reference documents; it is a copy, valid after the callback returns.
Event.Payload¶
| Go | |
|---|---|
Payload is SNBT parsed, once per event.
- Return type:
(*Nbt, error)
Event.Unresolved¶
| Go | |
|---|---|
Unresolved lists the fields the host could not resolve, from _unresolved. It is empty too when the payload does not parse, which CheckComplete does not count as complete.
- Return type:
[]string
Event.CheckComplete¶
| Go | |
|---|---|
CheckComplete reports whether the payload parsed and nothing in it is unresolved. A protection decision on an incomplete payload should refuse rather than guess.
- Return type:
bool
Event.Dim¶
| Go | |
|---|---|
Dim is the dimension the event happened in. An unreadable or incomplete payload is an error and never 0: read as the overworld it would let an event in a custom dimension pass a rule made for the overworld.
- Return type:
(int32, error)
Event.Set¶
| Go | |
|---|---|
Set writes key back into the event when the callback returns. Only the keys set go back, and the host merges them, so two listeners setting different keys keep both.
- Parameters:
- key :
string - value :
*Nbt
- key :
Event.Cancel¶
| Go | |
|---|---|
Cancel asks the host to cancel the event once the callback returns. An event that cannot be cancelled ignores it; the documentation of each event says whether it can be.
Event.Uncancel¶
| Go | |
|---|---|
Uncancel undoes a Cancel of this callback. A cancel made by an earlier listener stays.
Listener¶
Listener is one subscription, kept to end it.
Listener.Unsubscribe¶
| Go | |
|---|---|
Unsubscribe ends the subscription. Calling it twice is harmless. Server thread only.
- Return type:
error - Slots:
unsubscribe_event
ListenerHandle¶
ListenerHandle is an event listener as the host names it.
ListenerHandle.IsZero¶
| Go | |
|---|---|
IsZero reports whether the handle names nothing.
- Return type:
bool
Priority¶
| Go | |
|---|---|
Priority orders the listeners of one event; it mirrors ll::event::EventPriority.
| Name | Value | Description |
|---|---|---|
PriorityHighest |
0 |
|
PriorityHigh |
1 |
|
PriorityNormal |
2 |
|
PriorityLow |
3 |
|
PriorityLowest |
4 |