refactor: extract proxy & fix bungee chaneel

Signed-off-by: MiaoWoo <admin@yumc.pw>
This commit is contained in:
2020-09-24 10:31:20 +08:00
parent 6597b261fd
commit 9c137574f5
4 changed files with 168 additions and 159 deletions

View File

@ -6,20 +6,20 @@ const Bungee: net.md_5.bungee.api.ProxyServer = base.getInstance().getProxy()
@provideSingleton(channel.Channel)
export class BungeeChannel extends channel.Channel {
@inject(event.Event)
private eventManager: event.Event;
private eventManager: event.Event
send(player: any, channel: string, data: any) {
throw new Error("Method not implemented.");
throw new Error("Method not implemented.")
}
register(channel: string, listener: channel.ChannelListener) {
Bungee.registerChannel(channel);
Bungee.registerChannel(channel)
// console.console('§6[§eWARN§6] §eMiaoScript channel in BungeeCord only register. you need self hanler PluginMessageEvent!')
return this.eventManager.listen({ description: { name: channel } }, "PluginMessageEvent", (event: net.md_5.bungee.api.event.PluginMessageEvent) => {
listener(event.getData(), event)
})
}
unregister(channel: string, listener: any) {
Bungee.unregisterChannel(channel);
listener.off();
unregister(channel: string, off: any) {
Bungee.unregisterChannel(channel)
off()
}
}