From 2e679ff8b68e4da9daacdc5a0a740c8ceaa53e8e Mon Sep 17 00:00:00 2001 From: coding Date: Tue, 24 Oct 2017 11:38:35 +0000 Subject: [PATCH] =?UTF-8?q?fix:=20=E6=8F=90=E5=89=8D=E5=88=9D=E5=A7=8B?= =?UTF-8?q?=E5=8C=96log=E9=98=B2=E6=AD=A2=E5=86=85=E9=83=A8=E5=BC=82?= =?UTF-8?q?=E5=B8=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pom.xml | 2 +- src/main/resources/bios.js | 1 + src/main/resources/core/console.js | 6 ++++-- src/main/resources/plugins/MiaoTag.js | 12 ++++++------ 4 files changed, 12 insertions(+), 9 deletions(-) diff --git a/pom.xml b/pom.xml index c8cd7aa..96cbc70 100644 --- a/pom.xml +++ b/pom.xml @@ -3,7 +3,7 @@ 4.0.0 pw.yumc MiaoScript - 1.1.3 + 1.1.4 502647092 diff --git a/src/main/resources/bios.js b/src/main/resources/bios.js index 58c60ed..6eef615 100644 --- a/src/main/resources/bios.js +++ b/src/main/resources/bios.js @@ -1,4 +1,5 @@ 'use strict'; +var log = base.getLog().static; var boot; var disable; /** diff --git a/src/main/resources/core/console.js b/src/main/resources/core/console.js index 398c62c..f4c8438 100644 --- a/src/main/resources/core/console.js +++ b/src/main/resources/core/console.js @@ -2,7 +2,6 @@ * 控制台输出类 */ /*global base*/ -var log = base.getLog().static; (function(global){ var Arrays = Java.type('java.util.Arrays'); var Level = Java.type('java.util.logging.Level'); @@ -13,6 +12,7 @@ var log = base.getLog().static; }.bind(this), set: function (name) { this._name = name ? '[' + name + '] ' : ''; + this.prefix = name ? '§6[§b' + name + '§6]§r ' : ''; }.bind(this) }); this.name = name; @@ -29,8 +29,10 @@ var log = base.getLog().static; log.d(this.name + Array.prototype.join.call(arguments, ' ')); } this.sender = function () { + var sender = arguments[0]; + if (!(sender instanceof org.bukkit.command.CommandSender)) { console.error("第一个参数未实现 org.bukkit.command.CommandSender 无法发送消息!") } var args = Array.prototype.slice.call(arguments, 1); - log.sender(); + sender.sendMessage(this.prefix + args.join(' ')); } this.ex = function (ex) { log.console('§4' + ex); diff --git a/src/main/resources/plugins/MiaoTag.js b/src/main/resources/plugins/MiaoTag.js index 21f7763..371f1fc 100644 --- a/src/main/resources/plugins/MiaoTag.js +++ b/src/main/resources/plugins/MiaoTag.js @@ -55,11 +55,8 @@ function enable() { switch (subcommand) { case 'reload': self.reloadConfig(); + console.sender(sender, "§a配置文件重载完成!", "TEST"); break; - case 'test': - // var IllegalStateException = Java.type("java.lang.IllegalStateException"); - // throw new IllegalStateException('TEST'); - throw new TypeError('TEST'); } }, tab: function tab (sender, command, args){ @@ -68,14 +65,17 @@ function enable() { }) bukkit.players(function (p) fakeTag.set(p)); event.on(self, 'PlayerJoin', function (event) fakeTag.set(event.player)); - event.on(self, 'EntityDamage', function (event) { + var entityUpdate = function (event) { var player = event.entity; if(player instanceof org.bukkit.entity.Player){ setTimeout(function () { fakeTag.update(player); }, 1); } - }, false); + }; + event.on(self, 'EntityRegainHealth', entityUpdate, false); + event.on(self, 'EntityDamage', entityUpdate, false); + event.on(self, 'EntityRegainHealth', entityUpdate, false); //event.on(this, 'playerquitevent', function quit(event) removeTask(event.player)); }