2020-06-17 10:39:24 +00:00
|
|
|
import { server, MiaoScriptConsole, event, plugin } from "@ccms/api"
|
|
|
|
import { injectable, inject, postConstruct } from "@ccms/container"
|
|
|
|
import { getPluginMetadata } from "./utils"
|
2019-09-07 04:23:15 +00:00
|
|
|
|
2021-12-25 17:21:06 +00:00
|
|
|
const File = Java.type('java.io.File')
|
|
|
|
|
2019-09-07 04:23:15 +00:00
|
|
|
export namespace interfaces {
|
|
|
|
@injectable()
|
2020-06-02 10:01:56 +00:00
|
|
|
export abstract class Plugin implements plugin.Plugin {
|
2020-06-17 10:39:24 +00:00
|
|
|
public description: plugin.PluginMetadata
|
|
|
|
public logger: Console
|
2020-05-07 10:33:10 +00:00
|
|
|
@inject(server.Console)
|
2020-06-17 10:39:24 +00:00
|
|
|
private Console: MiaoScriptConsole
|
2019-09-07 04:23:15 +00:00
|
|
|
|
2020-05-07 10:33:10 +00:00
|
|
|
constructor() {
|
2020-01-17 09:45:13 +00:00
|
|
|
this.description = getPluginMetadata(this)
|
2020-05-07 10:33:10 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
@postConstruct()
|
|
|
|
private initialize() {
|
2020-01-17 09:45:13 +00:00
|
|
|
// @ts-ignore
|
2020-05-07 10:33:10 +00:00
|
|
|
this.logger = new this.Console(this.description.prefix || this.description.name)
|
2020-01-17 09:45:13 +00:00
|
|
|
}
|
|
|
|
|
2021-12-25 17:21:06 +00:00
|
|
|
public getDataFolder() {
|
|
|
|
let parent = new File(this.description.source).parent
|
|
|
|
let dataFolder = new File(parent, this.description.name)
|
|
|
|
return dataFolder.getAbsolutePath()
|
|
|
|
}
|
|
|
|
|
2019-09-07 04:23:15 +00:00
|
|
|
public load() { }
|
|
|
|
public enable() { }
|
|
|
|
public disable() { }
|
|
|
|
}
|
2020-06-17 10:39:24 +00:00
|
|
|
export interface ExecMetadata extends plugin.BaseMetadata {
|
2020-09-17 09:44:48 +00:00
|
|
|
/**
|
|
|
|
* 执行器所在对象 用于绑定this
|
|
|
|
*/
|
|
|
|
target?: any
|
2020-02-25 15:15:39 +00:00
|
|
|
/**
|
|
|
|
* 执行器
|
|
|
|
*/
|
2020-06-17 10:39:24 +00:00
|
|
|
executor?: string
|
2020-01-17 03:11:20 +00:00
|
|
|
}
|
|
|
|
export interface CommandMetadata extends ExecMetadata {
|
2020-09-22 09:33:59 +00:00
|
|
|
/**
|
|
|
|
* 命令别名
|
|
|
|
*/
|
|
|
|
alias?: string[]
|
2020-06-20 08:38:14 +00:00
|
|
|
/**
|
|
|
|
* 命令描述
|
|
|
|
*/
|
|
|
|
description?: string
|
2020-02-25 15:15:39 +00:00
|
|
|
/**
|
|
|
|
* 参数列表
|
|
|
|
*/
|
2020-06-17 10:39:24 +00:00
|
|
|
paramtypes?: string[]
|
2020-12-07 03:12:49 +00:00
|
|
|
/**
|
|
|
|
* 自动化主命令
|
|
|
|
*/
|
|
|
|
autoMain?: boolean
|
2022-04-01 09:18:32 +00:00
|
|
|
/**
|
|
|
|
* 子命令权限效验
|
|
|
|
*/
|
|
|
|
permission?: boolean | string
|
2019-09-19 10:59:32 +00:00
|
|
|
}
|
2020-01-17 03:11:20 +00:00
|
|
|
export interface ListenerMetadata extends ExecMetadata {
|
2020-04-24 07:38:00 +00:00
|
|
|
/**
|
|
|
|
* 监听优先级
|
|
|
|
*/
|
2020-06-17 10:39:24 +00:00
|
|
|
priority?: event.EventPriority
|
2020-04-24 07:38:00 +00:00
|
|
|
/**
|
|
|
|
* 是否忽略已取消的事件
|
|
|
|
*/
|
2020-06-17 10:39:24 +00:00
|
|
|
ignoreCancel?: boolean
|
2023-02-18 08:01:15 +00:00
|
|
|
/**
|
|
|
|
* 依赖插件 没有就不加载
|
|
|
|
*/
|
|
|
|
plugins?: string[]
|
2019-09-19 10:59:32 +00:00
|
|
|
}
|
2020-06-17 10:39:24 +00:00
|
|
|
export interface ConfigMetadata extends plugin.BaseMetadata {
|
2020-02-25 15:15:39 +00:00
|
|
|
/**
|
|
|
|
* 配置文件版本号
|
|
|
|
*/
|
2020-06-17 10:39:24 +00:00
|
|
|
version?: number
|
2020-12-17 08:58:37 +00:00
|
|
|
/**
|
|
|
|
* 默认配置
|
|
|
|
*/
|
|
|
|
default?: any
|
2020-02-25 15:15:39 +00:00
|
|
|
/**
|
|
|
|
* 实体变量名称
|
|
|
|
*/
|
2020-06-17 10:39:24 +00:00
|
|
|
variable?: string
|
2020-02-25 15:15:39 +00:00
|
|
|
/**
|
|
|
|
* 配置文件格式 默认 yml
|
|
|
|
*/
|
2020-06-17 10:39:24 +00:00
|
|
|
format?: string
|
2022-06-19 16:48:00 +00:00
|
|
|
/**
|
|
|
|
* 是否合并默认配置
|
|
|
|
*/
|
|
|
|
migrate?: boolean
|
2020-05-15 06:28:40 +00:00
|
|
|
/**
|
2020-10-31 03:40:38 +00:00
|
|
|
* 自动保存 默认为 false
|
2020-05-15 06:28:40 +00:00
|
|
|
*/
|
2020-10-31 03:40:38 +00:00
|
|
|
autosave?: boolean
|
2020-09-24 10:36:10 +00:00
|
|
|
/**
|
|
|
|
* 配置文件名称
|
|
|
|
*/
|
|
|
|
filename?: string
|
|
|
|
/**
|
|
|
|
* 配置文件全路径
|
|
|
|
*/
|
|
|
|
file?: any
|
2020-02-23 16:12:32 +00:00
|
|
|
}
|
2022-04-01 09:18:32 +00:00
|
|
|
export interface PlayerDataMetadata extends plugin.BaseMetadata {
|
|
|
|
/**
|
|
|
|
* 配置文件版本号
|
|
|
|
*/
|
|
|
|
version?: number
|
|
|
|
/**
|
|
|
|
* 默认配置
|
|
|
|
*/
|
|
|
|
default?: any
|
|
|
|
/**
|
|
|
|
* 实体变量名称
|
|
|
|
*/
|
|
|
|
variable?: string
|
|
|
|
/**
|
|
|
|
* 配置文件格式 默认 yml
|
|
|
|
*/
|
|
|
|
format?: string
|
|
|
|
/**
|
|
|
|
* 自动保存 默认为 false
|
|
|
|
*/
|
|
|
|
autosave?: boolean
|
|
|
|
/**
|
|
|
|
* 配置文件名称 默认玩家名称
|
|
|
|
*/
|
|
|
|
filename?: "username" | "uuid"
|
|
|
|
/**
|
|
|
|
* 配置文件目录 默认 playerdata
|
|
|
|
*/
|
|
|
|
dir?: string
|
|
|
|
/**
|
|
|
|
* 配置文件子目录 默认为空
|
|
|
|
*/
|
|
|
|
subdir?: string
|
|
|
|
}
|
2019-09-07 04:23:15 +00:00
|
|
|
}
|