feat: optimize api
Signed-off-by: MiaoWoo <admin@yumc.pw>
This commit is contained in:
parent
d06321d9b5
commit
34c598e6d8
@ -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 });
|
||||
}
|
||||
|
@ -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;
|
||||
|
@ -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') {
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
9
packages/api/src/interfaces/task.ts
Normal file
9
packages/api/src/interfaces/task.ts
Normal 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;
|
||||
}
|
||||
}
|
@ -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 };
|
||||
}
|
Loading…
Reference in New Issue
Block a user