feat: Optimizing Framework Code
Signed-off-by: MiaoWoo <admin@yumc.pw>
This commit is contained in:
parent
478bff9599
commit
8cf8dccbe4
@ -6,4 +6,4 @@
|
||||
/*global Java, base, module, exports, require*/
|
||||
function ItemHandlerDefault() {
|
||||
}
|
||||
exports = module.exports = Object.assign(new ItemHandlerDefault(), requireInternal('item'));;
|
||||
exports = module.exports = Object.assign(new ItemHandlerDefault(), requireInternal('item', true));;
|
||||
|
@ -43,8 +43,10 @@ var global = this;
|
||||
throw Error("Error class loader: " + classLoader.class.name + " Please contact the author MiaoWoo!");
|
||||
} else {
|
||||
log.info("Class loader compatible: " + classLoader.class.name);
|
||||
if (classLoader.parent) {
|
||||
log.info("Parent class loader: " + classLoader.parent.class.name);
|
||||
}
|
||||
}
|
||||
return classLoader;
|
||||
}
|
||||
|
||||
|
@ -5,6 +5,7 @@
|
||||
(function(global) {
|
||||
var Arrays = Java.type('java.util.Arrays');
|
||||
var Level = Java.type('java.util.logging.Level');
|
||||
var ignoreLogPrefix = ['java.', 'net.minecraft.', 'org.bukkit.', 'jdk.nashorn.'];
|
||||
global.ConsoleDefault = function ConsoleDefault(name) {
|
||||
Object.defineProperty(this, 'name', {
|
||||
get: function() {
|
||||
@ -44,12 +45,6 @@
|
||||
}.bind(this))
|
||||
};
|
||||
this.stack = function(ex) {
|
||||
// var exType = toString.call(ex)
|
||||
// if (exType !== "[object Error]") {
|
||||
// console.console('§6[WARN] Unknown Type', exType, ex)
|
||||
// ex.printStackTrace();
|
||||
// return []
|
||||
// }
|
||||
var stack = ex.getStackTrace();
|
||||
var cache = ['§4' + ex];
|
||||
if (stack.class) {
|
||||
@ -61,8 +56,16 @@
|
||||
fileName = fileName.indexOf('runtime') > -1 ? fileName.split('runtime')[1] : fileName;
|
||||
cache.push(' §e->§c %s => §4%s:%s'.format(fileName, trace.methodName, trace.lineNumber))
|
||||
} else {// %s.%s(§4%s:%s§c)
|
||||
var className = trace.className
|
||||
className = className.startsWith('jdk.nashorn.internal.scripts') ? className.substr(className.lastIndexOf('$') + 1) : className
|
||||
var className = trace.className;
|
||||
if (className.startsWith('jdk.nashorn.internal.scripts')) {
|
||||
className = className.substr(className.lastIndexOf('$') + 1)
|
||||
} else {
|
||||
for (var prefix in ignoreLogPrefix) {
|
||||
if (className.startsWith(ignoreLogPrefix[prefix])) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
cache.push(' §e->§c %s.%s(§4%s:%s§c)'.format(className, trace.methodName, trace.fileName, trace.lineNumber));
|
||||
}
|
||||
});
|
||||
|
@ -240,7 +240,7 @@
|
||||
file = _isFile(file) ? file : resolve(name, path);
|
||||
optional = Object.assign({ cache: true }, optional);
|
||||
if (file === undefined) {
|
||||
throw Error("Can't found module" + name + 'in directory' + path)
|
||||
throw Error("Can't found module " + name + " in directory " + path)
|
||||
}
|
||||
// 重定向文件名称和类型
|
||||
return getCacheModule(_canonical(file), file.name.split(".")[0], file, optional);
|
||||
|
@ -14,13 +14,21 @@ var nmsVersion = Bukkit.server.class.name.split('.')[3];
|
||||
* 获取NMS类
|
||||
*/
|
||||
function nmsCls(name) {
|
||||
try {
|
||||
return Java.type(['net.minecraft.server', nmsVersion, name].join('.'));
|
||||
} catch (e) {
|
||||
return base.getClass(['net.minecraft.server', nmsVersion, name].join('.'))
|
||||
}
|
||||
};
|
||||
/**
|
||||
* 获取OBC类
|
||||
*/
|
||||
function obcCls(name) {
|
||||
try {
|
||||
return Java.type(['org.bukkit.craftbukkit', nmsVersion, name].join('.'));
|
||||
} catch (e) {
|
||||
return base.getClass(['org.bukkit.craftbukkit', nmsVersion, name].join('.'))
|
||||
}
|
||||
};
|
||||
/**
|
||||
* 插件管理
|
||||
|
Loading…
Reference in New Issue
Block a user