feat: Optimization code
This commit is contained in:
parent
997820d117
commit
c2c17a46d4
@ -1,7 +1,6 @@
|
||||
'use strict';
|
||||
var log;
|
||||
var boot;
|
||||
var disable;
|
||||
// noinspection ThisExpressionReferencesGlobalObjectJS
|
||||
var global = this;
|
||||
/**
|
||||
@ -14,11 +13,11 @@ var global = this;
|
||||
// 开发环境下初始化
|
||||
root = root || "src/main/resources";
|
||||
if (__FILE__ !== "<eval>") {
|
||||
logger.info('载入自定义 BIOS 文件 ' + __FILE__);
|
||||
logger.info('Loading custom BIOS file ' + __FILE__);
|
||||
global.debug = true;
|
||||
}
|
||||
if (java.nio.file.Files.exists(java.nio.file.Paths.get(root, "debug"))) {
|
||||
logger.info('已开启调试模式!');
|
||||
logger.info('Running debugging mode...');
|
||||
global.debug = true;
|
||||
}
|
||||
// 检查类加载器 防止找不到核心文件
|
||||
@ -40,10 +39,10 @@ var global = this;
|
||||
var classLoader = java.lang.Thread.currentThread().contextClassLoader;
|
||||
pluginYml = classLoader.getResource("plugin.yml");
|
||||
if (pluginYml === null) {
|
||||
log.info("==================== ERROR ====================");
|
||||
log.info("异常的类加载器: " + classLoader.class.name);
|
||||
log.info("==================== ERROR ====================");
|
||||
throw Error('MiaoScript核心类库初始化失败 异常的类加载器!');
|
||||
engineDisable = function engineDisable() { }
|
||||
throw Error("Error class loader: " + classLoader.class.name + " Please contact the author MiaoWoo!");
|
||||
} else {
|
||||
log.info("Class loader compatible: " + classLoader.class.name);
|
||||
}
|
||||
return classLoader;
|
||||
}
|
||||
|
@ -7,7 +7,7 @@ var ServerType = {
|
||||
Sponge: 'sponge'
|
||||
};
|
||||
var MServer;
|
||||
var DetectServerType = ServerType.Bukkit;
|
||||
var DetectServerType;
|
||||
try {
|
||||
MServer = Java.type("org.bukkit.Bukkit");
|
||||
DetectServerType = ServerType.Bukkit;
|
||||
@ -23,9 +23,11 @@ try {
|
||||
/**
|
||||
* 尝试加载特殊的Console类
|
||||
*/
|
||||
if (DetectServerType) {
|
||||
try {
|
||||
load(root + '/internal/' + DetectServerType + '/console.js');
|
||||
} catch (ex) {
|
||||
// IGNORE
|
||||
}
|
||||
}
|
||||
global.console = new global.Console();
|
@ -15,10 +15,10 @@
|
||||
loadServerLib();
|
||||
loadPlugins();
|
||||
} catch (ex) {
|
||||
console.console("§4初始化插件基础系统库错误:§c", ex);
|
||||
console.console("§4Init plugin system lib failed! ERROR:§c", ex);
|
||||
console.ex(ex);
|
||||
}
|
||||
console.log('MiaoScript Engine Load Complete... Done (' + (new Date().getTime() - startTime) / 1000 + 's)!');
|
||||
console.log('MiaoScript engine loading completed... Done (' + (new Date().getTime() - startTime) / 1000 + 's)!');
|
||||
};
|
||||
|
||||
/**
|
||||
@ -38,8 +38,8 @@
|
||||
*/
|
||||
function loadRequire() {
|
||||
global.engineLoad = load;
|
||||
global.load = function __denyGlobalLoad__() {
|
||||
throw new Error('系统内部不许允许使用 load 如需执行脚本 请使用 engineLoad !');
|
||||
global.load = function __PreventGlobalLoadFunction__() {
|
||||
throw new Error('Internal engine system not allow use `load` function!');
|
||||
};
|
||||
// 初始化加载器
|
||||
global.require = engineLoad(root + '/core/require.js')(root);
|
||||
@ -53,7 +53,7 @@
|
||||
*/
|
||||
function loadPatch() {
|
||||
java.nio.file.Files.list(new java.io.File(root, 'core/patch').toPath()).forEach(function (path) {
|
||||
console.log('加载扩展类库', path);
|
||||
console.log('Loading ext lib', path);
|
||||
try {
|
||||
load(path.toFile());
|
||||
} catch (ex) {
|
||||
@ -93,7 +93,7 @@
|
||||
global.manager.load();
|
||||
global.manager.enable();
|
||||
} else {
|
||||
console.console('§4当前服务器不支持使用MiaoScript插件系统!');
|
||||
console.console('§4Current server does not support MiaoScript plugin system!' + DetectServerType);
|
||||
}
|
||||
}
|
||||
|
||||
@ -111,7 +111,7 @@
|
||||
server.shutdown();
|
||||
}
|
||||
} catch (ex) {
|
||||
console.console("§3MiaoScript Engine §aShutDown §4Error... ERR: ", ex);
|
||||
console.console("§3MiaoScript engine §ashutdown §4error... ERROR: ", ex);
|
||||
console.ex(ex);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user