cn.nukkit.event.EventHandler Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of powernukkit Show documentation
Show all versions of powernukkit Show documentation
A Minecraft Bedrock Edition server software implementation made in Java from scratch which supports all new features.
package cn.nukkit.event;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
/**
* 定义一个事件的处理器的注解。
* Annotation that defines a handler.
*
* 一个处理器的重要程度被称作处理器的优先级,优先级高的处理器有更多的决定权。参见:{@link #priority()}
* The importance of a handler is called its priority, handlers with higher priority speaks louder then
* lower ones. See: {@link #priority()}
*
* 处理器可以选择忽略或不忽略被取消的事件,这种特性可以在{@link #ignoreCancelled()}中定义。
* A handler can choose to ignore a cancelled event or not, that can be defined in {@link #ignoreCancelled()}.
*
* @author MagicDroidX(code) @ Nukkit Project
* @author null(javadoc) @ Nukkit Project
* @see cn.nukkit.event.Listener
* @see cn.nukkit.event.Event
* @since Nukkit 1.0 | Nukkit API 1.0.0
*/
@Target(ElementType.METHOD)
@Retention(RetentionPolicy.RUNTIME)
public @interface EventHandler {
/**
* 定义这个处理器的优先级。
* Define the priority of the handler.
*
* Nukkit调用处理器时会按照优先级从低到高的顺序调用,这样保证了高优先级的监听器能覆盖低优先级监听器做出的处理。
* 调用的先后顺序如下:
* When Nukkit calls all handlers, ones with lower priority is called earlier,
* that make handlers with higher priority can replace the decisions made by lower ones.
* The order that Nukkit call handlers is from the first to the last as:
*
* - EventPriority.LOWEST
*
- EventPriority.LOW
*
- EventPriority.NORMAL
*
- EventPriority.HIGH
*
- EventPriority.HIGHEST
*
- EventPriority.MONITOR
*
*
* @return 这个处理器的优先级。
The priority of this handler.
* @see cn.nukkit.event.EventHandler
*/
EventPriority priority() default EventPriority.NORMAL;
/**
* 定义这个处理器是否忽略被取消的事件。
* Define if the handler ignores a cancelled event.
*
* 如果为{@code true}而且事件发生,这个处理器不会被调用,反之相反。
* If ignoreCancelled is {@code true} and the event is cancelled, the method is
* not called. Otherwise, the method is always called.
*
* @return 这个处理器是否忽略被取消的事件。
Whether cancelled events should be ignored.
* @see cn.nukkit.event.EventHandler
*/
boolean ignoreCancelled() default false;
}