feat: 调整Console初始化逻辑

This commit is contained in:
coding
2018-01-03 14:00:29 +00:00
parent 2fcb7f1a1d
commit 035f887363
4 changed files with 96 additions and 102 deletions

View File

@ -0,0 +1,17 @@
/*global Java, base, module, exports, require, __FILE__*/
(function (global) {
global.Console = function BukkitConsole() {
ConsoleDefault.call(this);
this.sender = function () {
var sender = arguments[0];
if (!(sender instanceof org.bukkit.command.CommandSender)) {
this.error("第一个参数未实现 org.bukkit.command.CommandSender 无法发送消息!")
}
var args = Array.prototype.slice.call(arguments, 1);
sender.sendMessage(console.prefix + args.join(' '));
};
this.console = function () {
this.sender(MServer.consoleSender, Array.prototype.join.call(arguments, ' '));
};
};
})(global);