All Downloads are FREE. Search and download functionalities are using the official Maven repository.

cn.nukkit.event.Event Maven / Gradle / Ivy

Go to download

A Minecraft Bedrock Edition server software implementation made in Java from scratch which supports all new features.

There is a newer version: 1.6.0.1-PN
Show newest version
package cn.nukkit.event;

import cn.nukkit.utils.EventException;

/**
 * 描述服务器中可能发生的事情的类。
* Describes things that happens in the server. * *

服务器中可能发生的事情称作事件。定义一个需要它在一个事件发生时被运行的过程,这个过程称作监听器
* Things that happens in the server is called a event. Define a procedure that should be executed * when a event happens, this procedure is called a listener.

* *

Nukkit调用事件的处理器时,会通过参数的类型判断需要被监听的事件。
* When Nukkit is calling a handler, the event needed to listen is judged by the type of the parameter.

* *

关于监听器的实现,参阅:{@link Listener}
* For the way to implement a listener, see: {@link cn.nukkit.event.Listener}

* * @author Unknown(code) @ Nukkit Project * @author 粉鞋大妈(javadoc) @ Nukkit Project * @see cn.nukkit.event.EventHandler * @since Nukkit 1.0 | Nukkit API 1.0.0 */ public abstract class Event { protected String eventName = null; private boolean isCancelled = false; final public String getEventName() { return eventName == null ? getClass().getName() : eventName; } public boolean isCancelled() { if (!(this instanceof Cancellable)) { throw new EventException("Event is not Cancellable"); } return isCancelled; } public void setCancelled() { setCancelled(true); } public void setCancelled(boolean value) { if (!(this instanceof Cancellable)) { throw new EventException("Event is not Cancellable"); } isCancelled = value; } }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy