2020-07-28 01:39:52 +00:00
|
|
|
import { chat } from '@ccms/api'
|
|
|
|
import { provideSingleton } from '@ccms/container'
|
|
|
|
import bukkitChat from './enhance/chat'
|
|
|
|
|
|
|
|
@provideSingleton(chat.Chat)
|
|
|
|
export class BukkitChat extends chat.Chat {
|
2020-09-22 07:29:12 +00:00
|
|
|
sendJson(sender: any, json: string | object, type = 0) {
|
|
|
|
bukkitChat.send(sender, typeof json === "string" ? json : JSON.stringify(json), type)
|
|
|
|
}
|
2020-07-28 01:39:52 +00:00
|
|
|
sendMessage(sender: any, message: string) {
|
2020-09-22 07:29:12 +00:00
|
|
|
this.sendJson(sender, { text: message }, 0)
|
2020-07-28 01:39:52 +00:00
|
|
|
}
|
|
|
|
sendActionBar(sender: any, message: string) {
|
2020-09-22 07:29:12 +00:00
|
|
|
this.sendJson(sender, { text: message }, 2)
|
2020-07-28 01:39:52 +00:00
|
|
|
}
|
2020-09-17 09:44:48 +00:00
|
|
|
sendTitle(sender: any, title: string, subtitle: string = '', fadeIn: number = 20, time: number = 100, fadeOut: number = 20) {
|
2020-09-24 05:48:14 +00:00
|
|
|
try {
|
|
|
|
sender.sendTitle(title, subtitle, fadeIn, time, fadeOut)
|
|
|
|
} catch (error) {
|
|
|
|
sender.sendTitle(title, subtitle)
|
|
|
|
}
|
2020-07-28 01:39:52 +00:00
|
|
|
}
|
|
|
|
}
|