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'))) {
|
2019-09-07 04:23:15 +00:00
|
|
|
this.error("第一个参数未实现 org.bukkit.command.CommandSender 无法发送消息!")
|
|
|
|
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(' '));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
console(...args): void {
|
2019-09-19 10:58:01 +00:00
|
|
|
this.sender(Bukkit.getConsoleSender(), args.join(' '));
|
2019-09-07 04:23:15 +00:00
|
|
|
}
|
|
|
|
}
|