diff --git a/pom.xml b/pom.xml
index da14b0c..c2cf5c5 100644
--- a/pom.xml
+++ b/pom.xml
@@ -17,6 +17,9 @@
src/main/resources
+
+ plugins/**.js
+
true
@@ -49,7 +52,7 @@
-
+
diff --git a/src/main/resources/bios.js b/src/main/resources/bios.js
index fb819e1..0c2f663 100644
--- a/src/main/resources/bios.js
+++ b/src/main/resources/bios.js
@@ -28,12 +28,6 @@ var disable;
init(root);
} catch (ex) {
ex.printStackTrace();
- } finally {
- disable = function () {
- if (disablePlugins && typeof(disablePlugins) === "function") {
- disablePlugins();
- }
- }
}
};
diff --git a/src/main/resources/core/patch.js b/src/main/resources/core/ext/patch.js
similarity index 100%
rename from src/main/resources/core/patch.js
rename to src/main/resources/core/ext/patch.js
diff --git a/src/main/resources/core/init.js b/src/main/resources/core/init.js
index 81e8f45..2dd1307 100644
--- a/src/main/resources/core/init.js
+++ b/src/main/resources/core/init.js
@@ -2,86 +2,104 @@
var global = this;
/*global base*/
-// noinspection JSUnusedLocalSymbols
-function init(root) {
- global.root = root;
- global.noop = function () {};
- loadCore();
- loadRequire();
- loadPatch();
- loadServerLib();
- loadPlugins();
-}
-
-/**
- * 初始化核心
- */
-function loadCore() {
- // 加载基础模块
- load(root + '/core/ext.js');
- // 探测服务器类型
- load(root + '/core/detect.js');
- // 加载Console
- load(root + '/core/console.js');
-}
-
-/**
- * 初始化模块
- */
-function loadRequire() {
- // 初始化加载器
- global.require = load(root + '/core/require.js')(root);
-}
-
-/**
- * 加载补丁
- */
-function loadPatch() {
- // 加载补丁和扩展
- load(root + '/core/patch.js');
-}
-
-/**
- * 加载Bukkit的类库
- */
-function loadServerLib() {
- var task = require('api/task');
- global.setTimeout = function (func, time, _async) {
- return _async ? task.laterAsync(func, time) : task.later(func, time);
- };
- global.clearTimeout = function (task) {
- task.cancel();
- };
- global.setInterval = function (func, time, _async) {
- return _async ? task.timerAsync(func, time) : task.timer(func, time);
- };
- global.clearInterval = function (task) {
- task.cancel();
- };
-}
-
-/**
- * 加载JS插件
- */
-function loadPlugins() {
- // 初始化本体插件
- global.manager = require('api/plugin');
- if (manager) {
- manager.init('plugins');
- // 只有当在正式环境运行的时候才加载
- manager.load();
- manager.enable();
- } else {
- console.console('§4当前服务器不支持使用MiaoScript插件系统!');
+(function (global) {
+ // noinspection JSUnusedLocalSymbols
+ global.init = function init(root) {
+ global.root = root;
+ global.noop = function () {};
+ loadCore();
+ loadRequire();
+ try{
+ loadExt();
+ loadServerLib();
+ loadPlugins();
+ } catch (ex) {
+ console.console("§4初始化插件基础系统库错误:§c", ex);
+ console.ex(ex);
+ }
}
-}
-// noinspection JSUnusedLocalSymbols
-/**
- * 关闭插件Hook
- */
-function disablePlugins() {
- if (manager && manager.$) {
- manager.disable();
+ /**
+ * 初始化核心
+ */
+ function loadCore() {
+ // 加载基础模块
+ load(root + '/core/ext.js');
+ // 探测服务器类型
+ load(root + '/core/detect.js');
+ // 加载Console
+ load(root + '/core/console.js');
}
-}
\ No newline at end of file
+
+ /**
+ * 初始化模块
+ */
+ function loadRequire() {
+ // 初始化加载器
+ global.require = load(root + '/core/require.js')(root);
+ }
+
+ /**
+ * 加载补丁
+ */
+ function loadExt() {
+ var fs = require('core/fs');
+ fs.list(fs.file(root, 'core/ext')).forEach(function (path) {
+ console.log('加载扩展类库', path);
+ try{
+ load(path.toFile());
+ } catch (ex) {
+ console.ex(ex);
+ }
+ })
+ // 加载补丁和扩展
+ // load(root + '/core/patch.js');
+ // 加载underscore类库
+ // load('https://cdn.bootcss.com/underscore.js/1.8.3/underscore-min.js');
+ }
+
+ /**
+ * 加载Bukkit的类库
+ */
+ function loadServerLib() {
+ var task = require('api/task');
+ global.setTimeout = function (func, time, _async) {
+ return _async ? task.laterAsync(func, time) : task.later(func, time);
+ };
+ global.clearTimeout = function (task) {
+ task.cancel();
+ };
+ global.setInterval = function (func, time, _async) {
+ return _async ? task.timerAsync(func, time) : task.timer(func, time);
+ };
+ global.clearInterval = function (task) {
+ task.cancel();
+ };
+ }
+
+ /**
+ * 加载JS插件
+ */
+ function loadPlugins() {
+ // 初始化本体插件
+ global.manager = require('api/plugin');
+ if (global.manager) {
+ global.manager.init('plugins');
+ // 只有当在正式环境运行的时候才加载
+ global.manager.load();
+ global.manager.enable();
+ } else {
+ console.console('§4当前服务器不支持使用MiaoScript插件系统!');
+ }
+ }
+
+ // noinspection JSUnusedLocalSymbols
+ /**
+ * 关闭插件Hook
+ */
+ global.disable = function disable() {
+ if (global.manager && global.manager.$) {
+ global.manager.disable();
+ }
+ }
+})(global);
\ No newline at end of file