fix: 提前初始化log防止内部异常
This commit is contained in:
parent
2cab200e41
commit
2e679ff8b6
2
pom.xml
2
pom.xml
@ -3,7 +3,7 @@
|
|||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
<groupId>pw.yumc</groupId>
|
<groupId>pw.yumc</groupId>
|
||||||
<artifactId>MiaoScript</artifactId>
|
<artifactId>MiaoScript</artifactId>
|
||||||
<version>1.1.3</version>
|
<version>1.1.4</version>
|
||||||
<developers>
|
<developers>
|
||||||
<developer>
|
<developer>
|
||||||
<id>502647092</id>
|
<id>502647092</id>
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
var log = base.getLog().static;
|
||||||
var boot;
|
var boot;
|
||||||
var disable;
|
var disable;
|
||||||
/**
|
/**
|
||||||
|
@ -2,7 +2,6 @@
|
|||||||
* 控制台输出类
|
* 控制台输出类
|
||||||
*/
|
*/
|
||||||
/*global base*/
|
/*global base*/
|
||||||
var log = base.getLog().static;
|
|
||||||
(function(global){
|
(function(global){
|
||||||
var Arrays = Java.type('java.util.Arrays');
|
var Arrays = Java.type('java.util.Arrays');
|
||||||
var Level = Java.type('java.util.logging.Level');
|
var Level = Java.type('java.util.logging.Level');
|
||||||
@ -13,6 +12,7 @@ var log = base.getLog().static;
|
|||||||
}.bind(this),
|
}.bind(this),
|
||||||
set: function (name) {
|
set: function (name) {
|
||||||
this._name = name ? '[' + name + '] ' : '';
|
this._name = name ? '[' + name + '] ' : '';
|
||||||
|
this.prefix = name ? '§6[§b' + name + '§6]§r ' : '';
|
||||||
}.bind(this)
|
}.bind(this)
|
||||||
});
|
});
|
||||||
this.name = name;
|
this.name = name;
|
||||||
@ -29,8 +29,10 @@ var log = base.getLog().static;
|
|||||||
log.d(this.name + Array.prototype.join.call(arguments, ' '));
|
log.d(this.name + Array.prototype.join.call(arguments, ' '));
|
||||||
}
|
}
|
||||||
this.sender = function () {
|
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);
|
var args = Array.prototype.slice.call(arguments, 1);
|
||||||
log.sender();
|
sender.sendMessage(this.prefix + args.join(' '));
|
||||||
}
|
}
|
||||||
this.ex = function (ex) {
|
this.ex = function (ex) {
|
||||||
log.console('§4' + ex);
|
log.console('§4' + ex);
|
||||||
|
@ -55,11 +55,8 @@ function enable() {
|
|||||||
switch (subcommand) {
|
switch (subcommand) {
|
||||||
case 'reload':
|
case 'reload':
|
||||||
self.reloadConfig();
|
self.reloadConfig();
|
||||||
|
console.sender(sender, "§a配置文件重载完成!", "TEST");
|
||||||
break;
|
break;
|
||||||
case 'test':
|
|
||||||
// var IllegalStateException = Java.type("java.lang.IllegalStateException");
|
|
||||||
// throw new IllegalStateException('TEST');
|
|
||||||
throw new TypeError('TEST');
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
tab: function tab (sender, command, args){
|
tab: function tab (sender, command, args){
|
||||||
@ -68,14 +65,17 @@ function enable() {
|
|||||||
})
|
})
|
||||||
bukkit.players(function (p) fakeTag.set(p));
|
bukkit.players(function (p) fakeTag.set(p));
|
||||||
event.on(self, 'PlayerJoin', function (event) fakeTag.set(event.player));
|
event.on(self, 'PlayerJoin', function (event) fakeTag.set(event.player));
|
||||||
event.on(self, 'EntityDamage', function (event) {
|
var entityUpdate = function (event) {
|
||||||
var player = event.entity;
|
var player = event.entity;
|
||||||
if(player instanceof org.bukkit.entity.Player){
|
if(player instanceof org.bukkit.entity.Player){
|
||||||
setTimeout(function () {
|
setTimeout(function () {
|
||||||
fakeTag.update(player);
|
fakeTag.update(player);
|
||||||
}, 1);
|
}, 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));
|
//event.on(this, 'playerquitevent', function quit(event) removeTask(event.player));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user