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)
|
2020-09-24 02:31:20 +00:00
|
|
|
private eventManager: event.Event
|
2020-02-27 10:14:17 +00:00
|
|
|
|
2020-02-24 10:36:08 +00:00
|
|
|
send(player: any, channel: string, data: any) {
|
2020-09-24 02:31:20 +00:00
|
|
|
throw new Error("Method not implemented.")
|
2020-02-24 10:36:08 +00:00
|
|
|
}
|
|
|
|
register(channel: string, listener: channel.ChannelListener) {
|
2020-09-24 02:31:20 +00:00
|
|
|
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
|
|
|
}
|
2020-09-24 02:31:20 +00:00
|
|
|
unregister(channel: string, off: any) {
|
|
|
|
Bungee.unregisterChannel(channel)
|
|
|
|
off()
|
2020-02-24 10:36:08 +00:00
|
|
|
}
|
|
|
|
}
|