2019-09-07 04:23:15 +00:00
|
|
|
import { MiaoScriptConsole } from '@ms/api'
|
|
|
|
|
2019-09-19 10:58:01 +00:00
|
|
|
let Bukkit = 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!`)
|
2019-09-07 04:23:15 +00:00
|
|
|
return;
|
|
|
|
}
|
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 {
|
|
|
|
sender.sendMessage(this.prefix + args.join(' '));
|
|
|
|
}
|
|
|
|
}
|
2020-01-15 08:48:18 +00:00
|
|
|
console(...args: string[]): void {
|
2019-09-19 10:58:01 +00:00
|
|
|
this.sender(Bukkit.getConsoleSender(), args.join(' '));
|
2019-09-07 04:23:15 +00:00
|
|
|
}
|
|
|
|
}
|