@@ -1,14 +1,14 @@
|
||||
import { server, MiaoScriptConsole, event, plugin } from "@ccms/api";
|
||||
import { injectable, inject, postConstruct } from "@ccms/container";
|
||||
import { getPluginMetadata } from "./utils";
|
||||
import { server, MiaoScriptConsole, event, plugin } from "@ccms/api"
|
||||
import { injectable, inject, postConstruct } from "@ccms/container"
|
||||
import { getPluginMetadata } from "./utils"
|
||||
|
||||
export namespace interfaces {
|
||||
@injectable()
|
||||
export abstract class Plugin implements plugin.Plugin {
|
||||
public description: PluginMetadata;
|
||||
public logger: Console;
|
||||
public description: plugin.PluginMetadata
|
||||
public logger: Console
|
||||
@inject(server.Console)
|
||||
private Console: MiaoScriptConsole;
|
||||
private Console: MiaoScriptConsole
|
||||
|
||||
constructor() {
|
||||
this.description = getPluginMetadata(this)
|
||||
@@ -24,86 +24,45 @@ export namespace interfaces {
|
||||
public enable() { }
|
||||
public disable() { }
|
||||
}
|
||||
interface BaseMetadata {
|
||||
/**
|
||||
* 名称 为空则为对象名称
|
||||
*/
|
||||
name?: string;
|
||||
/**
|
||||
* 支持的服务器列表 为空则代表所有
|
||||
*/
|
||||
servers?: string[];
|
||||
}
|
||||
export interface PluginMetadata extends BaseMetadata {
|
||||
/**
|
||||
* 插件名称
|
||||
*/
|
||||
name: string;
|
||||
/**
|
||||
* 前缀
|
||||
*/
|
||||
prefix?: string;
|
||||
/**
|
||||
* 插件版本
|
||||
*/
|
||||
version: string;
|
||||
/**
|
||||
* 插件版本
|
||||
*/
|
||||
author: string | string[];
|
||||
/**
|
||||
* 插件源文件 必须指定为 __filename
|
||||
*/
|
||||
source: string;
|
||||
/**
|
||||
* 插件类型 默认为 ioc 执行 MiaoScript 加载逻辑
|
||||
*/
|
||||
type?: string;
|
||||
/**
|
||||
* 插件本体
|
||||
*/
|
||||
target?: any;
|
||||
}
|
||||
export interface ExecMetadata extends BaseMetadata {
|
||||
export interface ExecMetadata extends plugin.BaseMetadata {
|
||||
/**
|
||||
* 执行器
|
||||
*/
|
||||
executor?: string;
|
||||
executor?: string
|
||||
}
|
||||
export interface CommandMetadata extends ExecMetadata {
|
||||
/**
|
||||
* 参数列表
|
||||
*/
|
||||
paramtypes?: string[];
|
||||
paramtypes?: string[]
|
||||
}
|
||||
export interface ListenerMetadata extends ExecMetadata {
|
||||
/**
|
||||
* 监听优先级
|
||||
*/
|
||||
priority?: event.EventPriority;
|
||||
priority?: event.EventPriority
|
||||
/**
|
||||
* 是否忽略已取消的事件
|
||||
*/
|
||||
ignoreCancel?: boolean;
|
||||
|
||||
ignoreCancel?: boolean
|
||||
}
|
||||
export interface ConfigMetadata extends BaseMetadata {
|
||||
export interface ConfigMetadata extends plugin.BaseMetadata {
|
||||
/**
|
||||
* 配置文件版本号
|
||||
*/
|
||||
version?: number;
|
||||
version?: number
|
||||
/**
|
||||
* 实体变量名称
|
||||
*/
|
||||
variable?: string;
|
||||
variable?: string
|
||||
/**
|
||||
* 配置文件格式 默认 yml
|
||||
*/
|
||||
format?: string;
|
||||
format?: string
|
||||
/**
|
||||
* 是否为只读(关闭时将不会自动保存)
|
||||
*/
|
||||
readonly?: boolean;
|
||||
readonly?: boolean
|
||||
}
|
||||
export type PluginLike = Plugin | string;
|
||||
export type PluginLike = Plugin | string
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user