feat: channel add ext data

Signed-off-by: MiaoWoo <admin@yumc.pw>
This commit is contained in:
2020-02-27 18:14:17 +08:00
parent 0b416adfd2
commit e7d44af48c
5 changed files with 40 additions and 41 deletions

View File

@ -1,18 +1,25 @@
import { channel } from '@ms/api'
import { provideSingleton } from '@ms/container'
import { channel, event } from '@ms/api'
import { provideSingleton, inject } from '@ms/container'
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;
send(player: any, channel: string, data: any) {
throw new Error("Method not implemented.");
}
register(channel: string, listener: channel.ChannelListener) {
Bungee.registerChannel(channel);
console.console('§6[§eWARN§6] §eBungeeCord Channel only registerChannel you need self hanler PluginMessageEvent!')
// 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();
}
}