Commit 73cbb5b2 authored by liujiahua123123's avatar liujiahua123123

Server

parent dbd94bfd
package net.mamoe.mirai;
import net.mamoe.mirai.event.MiraiEventHook;
import net.mamoe.mirai.event.events.server.ServerDisableEvent;
/**
* @author Him188moe @ Mirai Project
*/
......@@ -11,5 +14,9 @@ public final class MiraiMain {
Runtime.getRuntime().addShutdownHook(new Thread(() -> {
server.shutdown();
}));
server.getEventManager().register(
new MiraiEventHook<>(ServerDisableEvent.class)
.setHandler(a -> System.out.println("close"))
);
}
}
......@@ -41,6 +41,12 @@ public class MiraiEventManager {
this.registerUntil(hook,(a) -> false);
}
public <D extends MiraiEvent> MiraiEventHook<D> onEvent(Class<D> event){
MiraiEventHook<D> hook = new MiraiEventHook<>(event);
this.register(hook);
return hook;
}
public void boardcastEvent(MiraiEvent event){
hooksLock.lock();
if(hooks.containsKey(event.getClass())){
......
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