From 72ae1b4b2947469f130bb9dfb054196797b63257 Mon Sep 17 00:00:00 2001 From: MiaoWoo Date: Tue, 26 Feb 2019 09:43:54 +0000 Subject: [PATCH] style: format code Signed-off-by: MiaoWoo --- src/main/resources/api/event.js | 6 ++--- src/main/resources/api/plugin.js | 24 +++++++++++--------- src/main/resources/internal/bukkit/server.js | 2 +- 3 files changed, 17 insertions(+), 15 deletions(-) diff --git a/src/main/resources/api/event.js b/src/main/resources/api/event.js index 82753c3..7b5ad57 100644 --- a/src/main/resources/api/event.js +++ b/src/main/resources/api/event.js @@ -135,7 +135,7 @@ function EventHandlerDefault() { var listenerMap = this.listenerMap; // 添加到缓存 用于关闭插件的时候关闭事件 if (!listenerMap[name]) listenerMap[name] = []; - var offExec = function () { + var offExec = function() { this.unregister(eventCls, listener); console.debug('插件 %s 注销事件 %s'.format(name, this.class2Name(eventCls))); }.bind(this); @@ -156,10 +156,10 @@ var EventHandler = Object.assign(new EventHandlerDefault(), requireInternal('eve console.info('%s 事件映射完毕 共计 %s 个事件!'.format(DetectServerType, EventHandler.mapEventName().toFixed(0))); module.exports = { on: EventHandler.listen.bind(EventHandler), - disable: function (jsp) { + disable: function(jsp) { var eventCache = EventHandler.listenerMap[jsp.description.name]; if (eventCache) { - eventCache.forEach(function (t) t.off.call(EventHandler)); + eventCache.forEach(function(t) { t.off.call(EventHandler) }); delete EventHandler.listenerMap[jsp.description.name]; } } diff --git a/src/main/resources/api/plugin.js b/src/main/resources/api/plugin.js index 2ae9124..db00262 100644 --- a/src/main/resources/api/plugin.js +++ b/src/main/resources/api/plugin.js @@ -92,7 +92,7 @@ function readPlugin(file) { } var plugin = require(file, { cache: false, - hook: function (origin) { + hook: function(origin) { return beforeLoadHook(origin); } }); @@ -172,7 +172,7 @@ function initPluginConfig(plugin) { * @constructor * @constructor (file|string) */ - plugin.getConfig = function () { + plugin.getConfig = function() { switch (arguments.length) { case 0: return plugin.config; @@ -181,7 +181,7 @@ function initPluginConfig(plugin) { if (!file.isFile) { file = plugin.getFile(file); } - return yaml.safeLoad(fs.read(file), {json: true}); + return yaml.safeLoad(fs.read(file), { json: true }); } }; /** @@ -189,7 +189,7 @@ function initPluginConfig(plugin) { * @constructor * @constructor (file|string) */ - plugin.reloadConfig = function () { + plugin.reloadConfig = function() { plugin.config = plugin.getConfig(plugin.configFile); }; /** @@ -197,7 +197,7 @@ function initPluginConfig(plugin) { * @constructor * @constructor (file, content) */ - plugin.saveConfig = function () { + plugin.saveConfig = function() { switch (arguments.length) { case 0: fs.save(plugin.configFile, yaml.safeDump(plugin.config)); @@ -273,13 +273,15 @@ function disable() { }); } +function reloadPlugin(p) { + disable(p); + p = loadPlugin(p.__FILE__); + load(p); + enable(p); +} + function reload() { - checkAndGet(arguments).forEach(function (p) { - disable(p); - p = loadPlugin(p.__FILE__); - load(p); - enable(p); - }); + checkAndGet(arguments).forEach(reloadPlugin); } // noinspection JSUnresolvedVariable diff --git a/src/main/resources/internal/bukkit/server.js b/src/main/resources/internal/bukkit/server.js index b074ccd..5809a42 100644 --- a/src/main/resources/internal/bukkit/server.js +++ b/src/main/resources/internal/bukkit/server.js @@ -9,7 +9,7 @@ var Bukkit = MServer; /** * 获取NMS版本 */ -var nmsVersion = Bukkit.class.name.split('.')[3]; +var nmsVersion = Bukkit.server.class.name.split('.')[3]; /** * 获取NMS类 */