feat: optimize api

Signed-off-by: MiaoWoo <admin@yumc.pw>
clean
MiaoWoo 2019-09-19 18:59:00 +08:00
parent dfa43d58f0
commit 15cea1dfc8
6 changed files with 23 additions and 23 deletions

View File

@ -14,11 +14,14 @@ export namespace command {
if (exec.tab && typeof exec.tab === "function") {
this.onTabComplete(plugin, cmd, exec.tab)
}
}
off(plugin: any, name: string) {
}
/**
* Create Server Command Object
*/
abstract create(plugin: object, opts: { name: string });
abstract create(name: string, opts: { name: string });
abstract onCommand(plugin: object, command: any, opts: { name: string });
abstract onTabComplete(plugin: object, command: any, opts: { name: string });
}

View File

@ -67,7 +67,6 @@ export class MiaoScriptConsole implements Console {
if (trace.className.startsWith('<')) {
var fileName = trace.fileName
if (fileName.startsWith(root)) { fileName = fileName.split(root)[1] }
if (fileName.startsWith('/runtime')) { fileName = fileName.split('/runtime')[1] }
cache.push(` §e->§c ${fileName} => §4${trace.methodName}:${trace.lineNumber}`)
} else {
var className = trace.className;

View File

@ -98,15 +98,15 @@ export namespace event {
/**
*
* @param jsp
* @param plugin
* @param event
* @param exec {function}
* @param priority [LOWEST,LOW,NORMAL,HIGH,HIGHEST,MONITOR]
* @param ignoreCancel
*/
listen(jsp, event, exec, priority, ignoreCancel) {
if (!jsp || !jsp.description || !jsp.description.name) throw new TypeError('插件名称为空 请检查传入参数!');
var name = jsp.description.name;
listen(plugin, event, exec, priority = 'NORMAL', ignoreCancel = false) {
if (!plugin || !plugin.description || !plugin.description.name) throw new TypeError('插件名称为空 请检查传入参数!');
var name = plugin.description.name;
var eventCls = this.name2Class(name, event);
if (!eventCls) { return; }
if (typeof priority === 'boolean') {

View File

@ -1,4 +1,4 @@
import { Container } from "inversify";
import { Container } from "@ms/container";
export namespace plugin {
/**
@ -18,8 +18,10 @@ export namespace plugin {
*/
export interface PluginManager {
scan(folder: string): void;
load(container: Container): void;
enable(): void;
disable(): void;
build(container: Container): void;
load(...args: any[]): void;
enable(...args: any[]): void;
disable(...args: any[]): void;
reload(...args: any[]): void;
}
}

View File

@ -0,0 +1,9 @@
export namespace task {
export const Task = Symbol('Task')
export interface Task {
run(func: Function): void;
async(func: Function): void;
later(tick: number): task.Task;
timer(tick: number): task.Task;
}
}

View File

@ -1,13 +0,0 @@
export interface CommandInfo {
aliases: string[];
description: string;
}
export interface PluginInfo {
description: PluginDescription;
}
export interface PluginDescription {
name: string;
version: string;
author: string;
commands: { [key: string]: CommandInfo };
}