@@ -135,7 +135,7 @@ function EventHandlerDefault() {
 | 
				
			|||||||
        var listenerMap = this.listenerMap;
 | 
					        var listenerMap = this.listenerMap;
 | 
				
			||||||
        // 添加到缓存 用于关闭插件的时候关闭事件
 | 
					        // 添加到缓存 用于关闭插件的时候关闭事件
 | 
				
			||||||
        if (!listenerMap[name]) listenerMap[name] = [];
 | 
					        if (!listenerMap[name]) listenerMap[name] = [];
 | 
				
			||||||
        var offExec = function () {
 | 
					        var offExec = function() {
 | 
				
			||||||
            this.unregister(eventCls, listener);
 | 
					            this.unregister(eventCls, listener);
 | 
				
			||||||
            console.debug('插件 %s 注销事件 %s'.format(name, this.class2Name(eventCls)));
 | 
					            console.debug('插件 %s 注销事件 %s'.format(name, this.class2Name(eventCls)));
 | 
				
			||||||
        }.bind(this);
 | 
					        }.bind(this);
 | 
				
			||||||
@@ -156,10 +156,10 @@ var EventHandler = Object.assign(new EventHandlerDefault(), requireInternal('eve
 | 
				
			|||||||
console.info('%s 事件映射完毕 共计 %s 个事件!'.format(DetectServerType, EventHandler.mapEventName().toFixed(0)));
 | 
					console.info('%s 事件映射完毕 共计 %s 个事件!'.format(DetectServerType, EventHandler.mapEventName().toFixed(0)));
 | 
				
			||||||
module.exports = {
 | 
					module.exports = {
 | 
				
			||||||
    on: EventHandler.listen.bind(EventHandler),
 | 
					    on: EventHandler.listen.bind(EventHandler),
 | 
				
			||||||
    disable: function (jsp) {
 | 
					    disable: function(jsp) {
 | 
				
			||||||
        var eventCache = EventHandler.listenerMap[jsp.description.name];
 | 
					        var eventCache = EventHandler.listenerMap[jsp.description.name];
 | 
				
			||||||
        if (eventCache) {
 | 
					        if (eventCache) {
 | 
				
			||||||
            eventCache.forEach(function (t) t.off.call(EventHandler));
 | 
					            eventCache.forEach(function(t) { t.off.call(EventHandler) });
 | 
				
			||||||
            delete EventHandler.listenerMap[jsp.description.name];
 | 
					            delete EventHandler.listenerMap[jsp.description.name];
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -92,7 +92,7 @@ function readPlugin(file) {
 | 
				
			|||||||
    }
 | 
					    }
 | 
				
			||||||
    var plugin = require(file, {
 | 
					    var plugin = require(file, {
 | 
				
			||||||
        cache: false,
 | 
					        cache: false,
 | 
				
			||||||
        hook: function (origin) {
 | 
					        hook: function(origin) {
 | 
				
			||||||
            return beforeLoadHook(origin);
 | 
					            return beforeLoadHook(origin);
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
    });
 | 
					    });
 | 
				
			||||||
@@ -172,7 +172,7 @@ function initPluginConfig(plugin) {
 | 
				
			|||||||
     * @constructor
 | 
					     * @constructor
 | 
				
			||||||
     * @constructor (file|string)
 | 
					     * @constructor (file|string)
 | 
				
			||||||
     */
 | 
					     */
 | 
				
			||||||
    plugin.getConfig = function () {
 | 
					    plugin.getConfig = function() {
 | 
				
			||||||
        switch (arguments.length) {
 | 
					        switch (arguments.length) {
 | 
				
			||||||
            case 0:
 | 
					            case 0:
 | 
				
			||||||
                return plugin.config;
 | 
					                return plugin.config;
 | 
				
			||||||
@@ -181,7 +181,7 @@ function initPluginConfig(plugin) {
 | 
				
			|||||||
                if (!file.isFile) {
 | 
					                if (!file.isFile) {
 | 
				
			||||||
                    file = plugin.getFile(file);
 | 
					                    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
 | 
				
			||||||
     * @constructor (file|string)
 | 
					     * @constructor (file|string)
 | 
				
			||||||
     */
 | 
					     */
 | 
				
			||||||
    plugin.reloadConfig = function () {
 | 
					    plugin.reloadConfig = function() {
 | 
				
			||||||
        plugin.config = plugin.getConfig(plugin.configFile);
 | 
					        plugin.config = plugin.getConfig(plugin.configFile);
 | 
				
			||||||
    };
 | 
					    };
 | 
				
			||||||
    /**
 | 
					    /**
 | 
				
			||||||
@@ -197,7 +197,7 @@ function initPluginConfig(plugin) {
 | 
				
			|||||||
     * @constructor
 | 
					     * @constructor
 | 
				
			||||||
     * @constructor (file, content)
 | 
					     * @constructor (file, content)
 | 
				
			||||||
     */
 | 
					     */
 | 
				
			||||||
    plugin.saveConfig = function () {
 | 
					    plugin.saveConfig = function() {
 | 
				
			||||||
        switch (arguments.length) {
 | 
					        switch (arguments.length) {
 | 
				
			||||||
            case 0:
 | 
					            case 0:
 | 
				
			||||||
                fs.save(plugin.configFile, yaml.safeDump(plugin.config));
 | 
					                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() {
 | 
					function reload() {
 | 
				
			||||||
    checkAndGet(arguments).forEach(function (p) {
 | 
					    checkAndGet(arguments).forEach(reloadPlugin);
 | 
				
			||||||
        disable(p);
 | 
					 | 
				
			||||||
        p = loadPlugin(p.__FILE__);
 | 
					 | 
				
			||||||
        load(p);
 | 
					 | 
				
			||||||
        enable(p);
 | 
					 | 
				
			||||||
    });
 | 
					 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// noinspection JSUnresolvedVariable
 | 
					// noinspection JSUnresolvedVariable
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -9,7 +9,7 @@ var Bukkit = MServer;
 | 
				
			|||||||
/**
 | 
					/**
 | 
				
			||||||
 * 获取NMS版本
 | 
					 * 获取NMS版本
 | 
				
			||||||
 */
 | 
					 */
 | 
				
			||||||
var nmsVersion = Bukkit.class.name.split('.')[3];
 | 
					var nmsVersion = Bukkit.server.class.name.split('.')[3];
 | 
				
			||||||
/**
 | 
					/**
 | 
				
			||||||
 * 获取NMS类
 | 
					 * 获取NMS类
 | 
				
			||||||
 */
 | 
					 */
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user