2020-05-02 16:14:47 +00:00
|
|
|
import { MiaoScriptConsole } from '@ccms/api'
|
2019-09-07 04:23:15 +00:00
|
|
|
|
2022-04-01 09:18:32 +00:00
|
|
|
const Bukkit: typeof org.bukkit.Bukkit = Java.type('org.bukkit.Bukkit')
|
2019-09-07 04:23:15 +00:00
|
|
|
|
|
|
|
export class BukkitConsole extends MiaoScriptConsole {
|
|
|
|
sender(sender, ...args) {
|
2019-09-25 02:10:35 +00:00
|
|
|
if (!(sender instanceof Java.type('org.bukkit.command.CommandSender'))) {
|
2020-01-15 08:48:18 +00:00
|
|
|
this.error(`First parameter ${sender} not instanceof org.bukkit.command.CommandSender can't send message!`)
|
2022-04-01 09:18:32 +00:00
|
|
|
return
|
2019-09-07 04:23:15 +00:00
|
|
|
}
|
2019-09-21 07:04:25 +00:00
|
|
|
if (Object.prototype.toString.call(args[0]) === "[object Array]") {
|
2019-09-07 04:23:15 +00:00
|
|
|
args[0].forEach(line => sender.sendMessage(this.prefix + line))
|
|
|
|
} else {
|
2022-04-01 09:18:32 +00:00
|
|
|
sender.sendMessage(this.prefix + args.join(' '))
|
2019-09-07 04:23:15 +00:00
|
|
|
}
|
|
|
|
}
|
2020-01-15 08:48:18 +00:00
|
|
|
console(...args: string[]): void {
|
2022-04-01 09:18:32 +00:00
|
|
|
this.sender(Bukkit.getConsoleSender(), args.join(' '))
|
2019-09-07 04:23:15 +00:00
|
|
|
}
|
|
|
|
}
|