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

top.jiaojinxin.jln.util.EventUtil Maven / Gradle / Ivy

There is a newer version: 0.1.7
Show newest version
package top.jiaojinxin.jln.util;

import top.jiaojinxin.jln.event.Event;
import top.jiaojinxin.jln.event.EventHandler;

import static top.jiaojinxin.jln.util.EventManager.getEventHandlerRepository;
import static top.jiaojinxin.jln.util.EventManager.getEventHandlers;
import static top.jiaojinxin.jln.util.EventManager.getEventPublisher;

/**
 * 

事件管理工具类

*

注意:由于相互之间的依赖关系,顾set方法调用有顺序,被需要的先调用

* * @author JiaoJinxin */ public class EventUtil { private EventUtil() { } /** * 静态增加事件处理器 * * @param eventHandler 事件处理器 * @author JiaoJinxin */ public static void addEventHandler(EventHandler eventHandler) { getEventHandlers().add(eventHandler); getEventHandlerRepository().register(eventHandler); } /** * 静态移除事件处理器 * * @param eventHandler 事件处理器 * @author JiaoJinxin */ public static void removeEventHandler(EventHandler eventHandler) { getEventHandlers().remove(eventHandler); getEventHandlerRepository().remove(eventHandler); } /** * 静态发布事件 * * @param event 事件 * @author JiaoJinxin */ public static void publish(Event event) { getEventPublisher().publish(event); } }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy