Commit 8117382f authored by Him188's avatar Him188

Add docs for event intercepting

parent 288c4cf5
...@@ -39,12 +39,18 @@ interface Event { ...@@ -39,12 +39,18 @@ interface Event {
* 事件是否已被拦截. * 事件是否已被拦截.
* *
* 所有事件都可以被拦截, 拦截后低优先级的监听器将不会处理到这个事件. * 所有事件都可以被拦截, 拦截后低优先级的监听器将不会处理到这个事件.
*
* @see intercept 拦截事件
*/ */
@SinceMirai("1.0.0") @SinceMirai("1.0.0")
val isIntercepted: Boolean val isIntercepted: Boolean
/** /**
* 拦截这个事件 * 拦截这个事件
*
* 当事件被 [拦截][Event.intercept] 后, 优先级较低 (靠右) 的监听器将不会被调用.
*
* @see [Listener.EventPriority] 查看优先级相关信息
*/ */
@SinceMirai("1.0.0") @SinceMirai("1.0.0")
fun intercept() fun intercept()
......
...@@ -92,6 +92,8 @@ interface Listener<in E : Event> : CompletableJob { ...@@ -92,6 +92,8 @@ interface Listener<in E : Event> : CompletableJob {
* - 使用 [MONITOR] 优先级的监听器将会被**并行**调用. * - 使用 [MONITOR] 优先级的监听器将会被**并行**调用.
* - 使用其他优先级的监听器都将会**按顺序**调用. * - 使用其他优先级的监听器都将会**按顺序**调用.
* 因此一个监听器的挂起可以阻塞事件处理过程而导致低优先级的监听器较晚处理. * 因此一个监听器的挂起可以阻塞事件处理过程而导致低优先级的监听器较晚处理.
*
* 当事件被 [拦截][Event.intercept] 后, 优先级较低 (靠右) 的监听器将不会被调用.
*/ */
@SinceMirai("1.0.0") @SinceMirai("1.0.0")
enum class EventPriority { enum class EventPriority {
...@@ -101,7 +103,8 @@ interface Listener<in E : Event> : CompletableJob { ...@@ -101,7 +103,8 @@ interface Listener<in E : Event> : CompletableJob {
/** /**
* 最低的优先级. * 最低的优先级.
* *
* 只监听事件而不拦截事件的监听器应使用此监听器. * 使用此优先级的监听器应遵循约束:
* - 不 [拦截事件][Event.intercept]
*/ */
MONITOR; MONITOR;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment