feat: update ms system
This commit is contained in:
		@@ -1,4 +1,4 @@
 | 
			
		||||
import { injectable } from "@ccms/container";
 | 
			
		||||
import { injectable } from "@ccms/container"
 | 
			
		||||
 | 
			
		||||
export namespace channel {
 | 
			
		||||
    /**
 | 
			
		||||
@@ -17,32 +17,32 @@ export namespace channel {
 | 
			
		||||
         * @param exec 执行器
 | 
			
		||||
         */
 | 
			
		||||
        listen(plugin: any, channel: string, exec: ChannelListener) {
 | 
			
		||||
            if (!plugin || !plugin.description || !plugin.description.name) throw new TypeError('Plugin can\'t be undefiend!');
 | 
			
		||||
            let name = plugin.description.name;
 | 
			
		||||
            if (!plugin || !plugin.description || !plugin.description.name) throw new TypeError('Plugin can\'t be undefiend!')
 | 
			
		||||
            let name = plugin.description.name
 | 
			
		||||
            let listener = this.register(channel, exec)
 | 
			
		||||
            if (!this.listenerMap[name]) this.listenerMap[name] = [];
 | 
			
		||||
            if (!this.listenerMap[name]) this.listenerMap[name] = []
 | 
			
		||||
            let offExec = () => {
 | 
			
		||||
                this.unregister(channel, listener);
 | 
			
		||||
                console.debug(`[${name}] unregister channel ${channel}`);
 | 
			
		||||
            };
 | 
			
		||||
                this.unregister(channel, listener)
 | 
			
		||||
                console.debug(`[${name}] unregister channel ${channel}`)
 | 
			
		||||
            }
 | 
			
		||||
            var off = {
 | 
			
		||||
                channel,
 | 
			
		||||
                listener,
 | 
			
		||||
                off: offExec
 | 
			
		||||
            };
 | 
			
		||||
            this.listenerMap[name].push(off);
 | 
			
		||||
            console.debug(`[${name}] register channel ${channel} => ${exec.name || '[anonymous]'}`);
 | 
			
		||||
            return off;
 | 
			
		||||
            }
 | 
			
		||||
            this.listenerMap[name].push(off)
 | 
			
		||||
            console.debug(`[${name}] register channel ${channel} => ${exec.name || '[anonymous]'}`)
 | 
			
		||||
            return off
 | 
			
		||||
        }
 | 
			
		||||
        /**
 | 
			
		||||
         * 关闭插件注册的通道
 | 
			
		||||
         * @param plugin 插件
 | 
			
		||||
         */
 | 
			
		||||
        disable(plugin: any) {
 | 
			
		||||
            var channelCache = this.listenerMap[plugin.description.name];
 | 
			
		||||
            var channelCache = this.listenerMap[plugin.description.name]
 | 
			
		||||
            if (channelCache) {
 | 
			
		||||
                channelCache.forEach(t => t.off());
 | 
			
		||||
                delete this.listenerMap[plugin.description.name];
 | 
			
		||||
                channelCache.forEach(t => t.off())
 | 
			
		||||
                delete this.listenerMap[plugin.description.name]
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
        /**
 | 
			
		||||
 
 | 
			
		||||
@@ -1,4 +1,7 @@
 | 
			
		||||
import { injectable } from '@ccms/container'
 | 
			
		||||
 | 
			
		||||
export namespace chat {
 | 
			
		||||
    @injectable()
 | 
			
		||||
    export abstract class Chat {
 | 
			
		||||
        sendMessage(sender: any, message: string) {
 | 
			
		||||
            throw new Error("Method not implemented.")
 | 
			
		||||
@@ -9,7 +12,7 @@ export namespace chat {
 | 
			
		||||
        clearActionBar(sender: any) {
 | 
			
		||||
            this.sendActionBar(sender, '')
 | 
			
		||||
        }
 | 
			
		||||
        sendTitle(sender: any, title: string, subtitle: string = '', fadeIn: number = 1, time: number = 5, fadeOut: number = 1) {
 | 
			
		||||
        sendTitle(sender: any, title: string, subtitle: string = '', fadeIn: number = 20, time: number = 100, fadeOut: number = 20) {
 | 
			
		||||
            throw new Error("Method not implemented.")
 | 
			
		||||
        }
 | 
			
		||||
        clearTitle(sender: any) {
 | 
			
		||||
 
 | 
			
		||||
@@ -130,23 +130,20 @@ export namespace event {
 | 
			
		||||
            }
 | 
			
		||||
            priority = priority || EventPriority.NORMAL
 | 
			
		||||
            ignoreCancel = ignoreCancel || false
 | 
			
		||||
            // @ts-ignore
 | 
			
		||||
            let executor = exec.name || exec.executor || '[anonymous]'
 | 
			
		||||
            // noinspection JSUnusedGlobalSymbols
 | 
			
		||||
            var listener = this.register(eventCls, this.execute(name, exec, eventCls), priority, ignoreCancel)
 | 
			
		||||
            var listenerMap = this.listenerMap
 | 
			
		||||
            // add to cache Be used for close plugin to close event
 | 
			
		||||
            if (!listenerMap[name]) listenerMap[name] = []
 | 
			
		||||
            var offExec = () => {
 | 
			
		||||
            var off = () => {
 | 
			
		||||
                this.unregister(eventCls, listener)
 | 
			
		||||
                console.debug(i18n.translate("ms.api.event.unregister", { name, event: this.class2Name(eventCls), exec: exec.name || '[anonymous]' }))
 | 
			
		||||
            }
 | 
			
		||||
            var off = {
 | 
			
		||||
                event: eventCls,
 | 
			
		||||
                listener: listener,
 | 
			
		||||
                off: offExec
 | 
			
		||||
                console.debug(i18n.translate("ms.api.event.unregister", { name, event: this.class2Name(eventCls), exec: executor }))
 | 
			
		||||
            }
 | 
			
		||||
            listenerMap[name].push(off)
 | 
			
		||||
            // noinspection JSUnresolvedVariable
 | 
			
		||||
            console.debug(i18n.translate("ms.api.event.register", { name, event: this.class2Name(eventCls), exec: exec.name || '[anonymous]' }))
 | 
			
		||||
            console.debug(i18n.translate("ms.api.event.register", { name, event: this.class2Name(eventCls), exec: executor }))
 | 
			
		||||
            return off
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
@@ -157,7 +154,7 @@ export namespace event {
 | 
			
		||||
        disable(plugin: any) {
 | 
			
		||||
            var eventCache = this.listenerMap[plugin.description.name]
 | 
			
		||||
            if (eventCache) {
 | 
			
		||||
                eventCache.forEach(t => t.off())
 | 
			
		||||
                eventCache.forEach(off => off())
 | 
			
		||||
                delete this.listenerMap[plugin.description.name]
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
 
 | 
			
		||||
@@ -38,10 +38,6 @@ export namespace plugin {
 | 
			
		||||
         * 插件加载类型
 | 
			
		||||
         */
 | 
			
		||||
        type: string
 | 
			
		||||
        /**
 | 
			
		||||
         * 插件名称
 | 
			
		||||
         */
 | 
			
		||||
        name?: string
 | 
			
		||||
        /**
 | 
			
		||||
         * 插件文件
 | 
			
		||||
         */
 | 
			
		||||
@@ -116,22 +112,22 @@ export namespace plugin {
 | 
			
		||||
         * Load 阶段
 | 
			
		||||
         * @param plugin 插件
 | 
			
		||||
         */
 | 
			
		||||
        load(plugin: Plugin): void
 | 
			
		||||
        load?(plugin: Plugin): void
 | 
			
		||||
        /**
 | 
			
		||||
         * Enable 阶段
 | 
			
		||||
         * @param plugin 插件
 | 
			
		||||
         */
 | 
			
		||||
        enable(plugin: Plugin): void
 | 
			
		||||
        enable?(plugin: Plugin): void
 | 
			
		||||
        /**
 | 
			
		||||
         * Disable 阶段
 | 
			
		||||
         * @param plugin 插件
 | 
			
		||||
         */
 | 
			
		||||
        disable(plugin: Plugin): void
 | 
			
		||||
        disable?(plugin: Plugin): void
 | 
			
		||||
        /**
 | 
			
		||||
         * Reload 阶段
 | 
			
		||||
         * @param plugin 插件
 | 
			
		||||
         */
 | 
			
		||||
        reload(plugin: Plugin): void
 | 
			
		||||
        reload?(plugin: Plugin): void
 | 
			
		||||
    }
 | 
			
		||||
    export interface Plugin {
 | 
			
		||||
        description: PluginMetadata
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user