mirror of
https://github.com/mamoe/mirai.git
synced 2025-01-19 13:04:43 +08:00
Server
This commit is contained in:
parent
dbd94bfdff
commit
73cbb5b2d1
@ -1,6 +1,9 @@
|
||||
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())){
|
||||
|
Loading…
Reference in New Issue
Block a user