feat: add remove plugin on disable

Signed-off-by: MiaoWoo <admin@yumc.pw>
This commit is contained in:
2019-09-22 18:00:18 +08:00
parent 1ea93dfb9f
commit b3c2def36d
5 changed files with 53 additions and 16 deletions

View File

@ -16,16 +16,18 @@ export namespace command {
}
}
off(plugin: any, name: string) {
console.debug(`插件 ${plugin.description.name} 注销命令 ${name}...`)
this.remove(plugin, name);
}
/**
* Create Server Command Object
*/
abstract create(plugin: any, command: string);
abstract onCommand(plugin: any, command: any, executor: Function);
abstract onTabComplete(plugin: any, command: any, tabCompleter: Function);
protected abstract create(plugin: any, command: string);
protected abstract remove(plugin: any, command: string);
protected abstract onCommand(plugin: any, command: any, executor: Function);
protected abstract onTabComplete(plugin: any, command: any, tabCompleter: Function);
setExecutor(plugin: any, command: any, executor: Function) {
protected setExecutor(plugin: any, command: any, executor: Function) {
return (sender: any, _, command: string, args: string[]) => {
try {
return executor(sender, command, Java.from(args));
@ -38,7 +40,7 @@ export namespace command {
}
}
setTabCompleter(plugin: any, command: any, tabCompleter: Function) {
protected setTabCompleter(plugin: any, command: any, tabCompleter: Function) {
return (sender: any, _, command: string, args: string[]) => {
try {
var token = args[args.length - 1];

View File

@ -23,5 +23,6 @@ export namespace plugin {
enable(...args: any[]): void;
disable(...args: any[]): void;
reload(...args: any[]): void;
getPlugins(): Map<string, any>;
}
}