2020-05-02 16:14:47 +00:00
|
|
|
import { channel, event } from '@ccms/api'
|
|
|
|
import { provideSingleton, inject } from '@ccms/container'
|
2020-02-24 10:36:08 +00:00
|
|
|
|
|
|
|
const Bungee: net.md_5.bungee.api.ProxyServer = base.getInstance().getProxy()
|
|
|
|
|
2020-02-26 02:15:33 +00:00
|
|
|
@provideSingleton(channel.Channel)
|
2020-02-24 10:36:08 +00:00
|
|
|
export class BungeeChannel extends channel.Channel {
|
2020-02-27 10:14:17 +00:00
|
|
|
@inject(event.Event)
|
|
|
|
private eventManager: event.Event;
|
|
|
|
|
2020-02-24 10:36:08 +00:00
|
|
|
send(player: any, channel: string, data: any) {
|
|
|
|
throw new Error("Method not implemented.");
|
|
|
|
}
|
|
|
|
register(channel: string, listener: channel.ChannelListener) {
|
|
|
|
Bungee.registerChannel(channel);
|
2020-02-27 10:14:17 +00:00
|
|
|
// 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)
|
|
|
|
})
|
2020-02-24 10:36:08 +00:00
|
|
|
}
|
|
|
|
unregister(channel: string, listener: any) {
|
|
|
|
Bungee.unregisterChannel(channel);
|
2020-02-27 10:14:17 +00:00
|
|
|
listener.off();
|
2020-02-24 10:36:08 +00:00
|
|
|
}
|
|
|
|
}
|