feat: add plugin checker

Signed-off-by: MiaoWoo <admin@yumc.pw>
This commit is contained in:
2023-02-18 16:01:15 +08:00
parent dd76e563c8
commit 07a5d0c8de
4 changed files with 38 additions and 7 deletions

View File

@@ -29,6 +29,7 @@ export namespace server {
origin: any
[key: string]: any
}
@injectable()
export abstract class NativePluginManager {
list(): NativePlugin[] {
@@ -53,6 +54,7 @@ export namespace server {
throw new Error("Method not implemented.")
}
}
/**
* MiaoScript Server
*/
@@ -98,6 +100,7 @@ export namespace server {
throw new Error("Method not implemented.")
}
}
@injectable()
export class ServerChecker {
@Autowired(ServerType)
@@ -116,6 +119,22 @@ export namespace server {
}
}
}
@injectable()
export class NativePluginChecker {
@Autowired(NativePluginManager)
private nativePluginManager: NativePluginManager
check(plugins: string[]) {
// Not set plugins -> allow
if (!plugins || !plugins.length) return true
for (const plugin of plugins) {
if (!this.nativePluginManager.has(plugin)) { return false }
}
return true
}
}
@injectable()
export abstract class ReflectServer extends server.Server {
@Autowired(ContainerInstance)