mirror of
https://github.com/mamoe/mirai.git
synced 2025-03-08 11:01:19 +08:00
Add docs for event intercepting
This commit is contained in:
parent
288c4cf5fa
commit
8117382f74
mirai-core/src/commonMain/kotlin/net.mamoe.mirai/event
@ -39,12 +39,18 @@ interface Event {
|
||||
* 事件是否已被拦截.
|
||||
*
|
||||
* 所有事件都可以被拦截, 拦截后低优先级的监听器将不会处理到这个事件.
|
||||
*
|
||||
* @see intercept 拦截事件
|
||||
*/
|
||||
@SinceMirai("1.0.0")
|
||||
val isIntercepted: Boolean
|
||||
|
||||
/**
|
||||
* 拦截这个事件
|
||||
*
|
||||
* 当事件被 [拦截][Event.intercept] 后, 优先级较低 (靠右) 的监听器将不会被调用.
|
||||
*
|
||||
* @see [Listener.EventPriority] 查看优先级相关信息
|
||||
*/
|
||||
@SinceMirai("1.0.0")
|
||||
fun intercept()
|
||||
|
@ -92,6 +92,8 @@ interface Listener<in E : Event> : CompletableJob {
|
||||
* - 使用 [MONITOR] 优先级的监听器将会被**并行**调用.
|
||||
* - 使用其他优先级的监听器都将会**按顺序**调用.
|
||||
* 因此一个监听器的挂起可以阻塞事件处理过程而导致低优先级的监听器较晚处理.
|
||||
*
|
||||
* 当事件被 [拦截][Event.intercept] 后, 优先级较低 (靠右) 的监听器将不会被调用.
|
||||
*/
|
||||
@SinceMirai("1.0.0")
|
||||
enum class EventPriority {
|
||||
@ -101,7 +103,8 @@ interface Listener<in E : Event> : CompletableJob {
|
||||
/**
|
||||
* 最低的优先级.
|
||||
*
|
||||
* 只监听事件而不拦截事件的监听器应使用此监听器.
|
||||
* 使用此优先级的监听器应遵循约束:
|
||||
* - 不 [拦截事件][Event.intercept]
|
||||
*/
|
||||
MONITOR;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user