refactor: chat & command tabComplete

Signed-off-by: MiaoWoo <admin@yumc.pw>
This commit is contained in:
2020-09-22 15:29:12 +08:00
parent 68a996f830
commit af85703bd9
10 changed files with 85 additions and 75 deletions

View File

@ -4,11 +4,14 @@ import bukkitChat from './enhance/chat'
@provideSingleton(chat.Chat)
export class BukkitChat extends chat.Chat {
sendJson(sender: any, json: string | object, type = 0) {
bukkitChat.send(sender, typeof json === "string" ? json : JSON.stringify(json), type)
}
sendMessage(sender: any, message: string) {
bukkitChat.send(sender, JSON.stringify({ text: message }), 0)
this.sendJson(sender, { text: message }, 0)
}
sendActionBar(sender: any, message: string) {
bukkitChat.send(sender, JSON.stringify({ text: message }), 2)
this.sendJson(sender, { text: message }, 2)
}
sendTitle(sender: any, title: string, subtitle: string = '', fadeIn: number = 20, time: number = 100, fadeOut: number = 20) {
sender.sendTitle(title, subtitle, fadeIn, time, fadeOut)