Zig:事件¶
函数¶
subscribe¶
| Zig | |
|---|---|
对这个 id 的每一个事件,在服务器线程上调用 handler。只能在服务器线程调用。
- 参数:
- id :
[]const u8 - priority :
Priority - handler :
comptime fn (*const Event) void
- id :
- 返回值类型:
Error!Listener - 对应槽位:
subscribe_event
Event¶
| Zig | |
|---|---|
监听器收到的一个事件;id 和 snbt 只在回调期间有效。
Event.writeBack¶
| Zig | |
|---|---|
把键写回事件里,SNBT 中只放要改的键;宿主会合并它们,所以两个监听器写不同的键时,两边的改动都会保留。
- 参数:
- edit :
[]const u8
- edit :
- 返回值类型:
void
Event.cancel¶
| Zig | |
|---|---|
请求宿主取消这个事件。不能取消的事件会忽略这个请求。
- 返回值类型:
void
Listener¶
一个订阅,保存下来用来结束它。
Listener.unsubscribe¶
| Zig | |
|---|---|
结束订阅;调用两次也没有问题。只能在服务器线程调用。
- 返回值类型:
Error!void - 对应槽位:
unsubscribe_event
Priority¶
监听器的顺序,对应 ll::event::EventPriority。