feat: 更新插件管理模块
Signed-off-by: MiaoWoo <admin@yumc.pw>
This commit is contained in:
parent
8a2b0d7c2e
commit
7afea75454
@ -14,10 +14,10 @@ export class BukkitNativePluginManager extends server.NativePluginManager {
|
|||||||
return Java.from(this.bukkitPluginManager.getPlugins()).map(plugin => this.convert(plugin))
|
return Java.from(this.bukkitPluginManager.getPlugins()).map(plugin => this.convert(plugin))
|
||||||
}
|
}
|
||||||
has(name: string): boolean {
|
has(name: string): boolean {
|
||||||
return !!Bukkit.getPluginManager().getPlugin(name)
|
return !!this.bukkitPluginManager.getPlugin(name)
|
||||||
}
|
}
|
||||||
get(name: string): server.NativePlugin {
|
get(name: string): server.NativePlugin {
|
||||||
return this.convert(Bukkit.getPluginManager().getPlugin(name))
|
return this.convert(this.bukkitPluginManager.getPlugin(name))
|
||||||
}
|
}
|
||||||
|
|
||||||
private convert(plugin: org.bukkit.plugin.Plugin): server.NativePlugin {
|
private convert(plugin: org.bukkit.plugin.Plugin): server.NativePlugin {
|
||||||
|
@ -3,10 +3,34 @@ import { server } from '@ccms/api'
|
|||||||
let Bungee: net.md_5.bungee.api.ProxyServer = base.getInstance().getProxy()
|
let Bungee: net.md_5.bungee.api.ProxyServer = base.getInstance().getProxy()
|
||||||
|
|
||||||
export class BungeeNativePluginManager extends server.NativePluginManager {
|
export class BungeeNativePluginManager extends server.NativePluginManager {
|
||||||
has(name: string) {
|
private bungeePluginManager: net.md_5.bungee.api.plugin.PluginManager
|
||||||
return !!this.get(name)
|
|
||||||
|
constructor() {
|
||||||
|
super()
|
||||||
|
this.bungeePluginManager = Bungee.getPluginManager()
|
||||||
|
}
|
||||||
|
|
||||||
|
list(): server.NativePlugin[] {
|
||||||
|
return Java.from(this.bungeePluginManager.getPlugins()).map(plugin => this.convert(plugin))
|
||||||
|
}
|
||||||
|
has(name: string): boolean {
|
||||||
|
return !!this.bungeePluginManager.getPlugin(name)
|
||||||
|
}
|
||||||
|
get(name: string): server.NativePlugin {
|
||||||
|
return this.convert(this.bungeePluginManager.getPlugin(name))
|
||||||
|
}
|
||||||
|
|
||||||
|
private convert(plugin: net.md_5.bungee.api.plugin.Plugin): server.NativePlugin {
|
||||||
|
if (!plugin) return plugin as any
|
||||||
|
let desc = plugin.getDescription()
|
||||||
|
return {
|
||||||
|
name: desc.getName(),
|
||||||
|
version: desc.getVersion(),
|
||||||
|
authors: [desc.getAuthor()],
|
||||||
|
depends: Java.from(desc.getDepends()) as any,
|
||||||
|
softDepends: Java.from(desc.getSoftDepends()) as any,
|
||||||
|
enable: true,
|
||||||
|
origin: plugin
|
||||||
}
|
}
|
||||||
get(name: string) {
|
|
||||||
return Bungee.getPluginManager().getPlugin(name)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -3,10 +3,34 @@ import { server } from '@ccms/api'
|
|||||||
let Nukkit: cn.nukkit.Server = base.getInstance().getServer()
|
let Nukkit: cn.nukkit.Server = base.getInstance().getServer()
|
||||||
|
|
||||||
export class NukkitNativePluginManager extends server.NativePluginManager {
|
export class NukkitNativePluginManager extends server.NativePluginManager {
|
||||||
|
private nukkitPluginManager: cn.nukkit.plugin.PluginManager
|
||||||
|
|
||||||
|
constructor() {
|
||||||
|
super()
|
||||||
|
this.nukkitPluginManager = Nukkit.getPluginManager()
|
||||||
|
}
|
||||||
|
|
||||||
|
list(): server.NativePlugin[] {
|
||||||
|
return Java.from(this.nukkitPluginManager.getPlugins().values()).map(plugin => this.convert(plugin))
|
||||||
|
}
|
||||||
has(name: string) {
|
has(name: string) {
|
||||||
return !!this.get(name)
|
return !!this.nukkitPluginManager.getPlugin(name)
|
||||||
}
|
}
|
||||||
get(name: string) {
|
get(name: string) {
|
||||||
return Nukkit.getPluginManager().getPlugin(name)
|
return this.convert(this.nukkitPluginManager.getPlugin(name))
|
||||||
|
}
|
||||||
|
|
||||||
|
private convert(plugin: cn.nukkit.plugin.Plugin): server.NativePlugin {
|
||||||
|
if (!plugin) return plugin as any
|
||||||
|
let desc = plugin.getDescription()
|
||||||
|
return {
|
||||||
|
name: plugin.getName(),
|
||||||
|
version: desc.getVersion(),
|
||||||
|
authors: Java.from(desc.getAuthors() as string[]),
|
||||||
|
depends: Java.from(desc.getDepend() as string[]),
|
||||||
|
softDepends: Java.from(desc.getSoftDepend() as string[]),
|
||||||
|
enable: plugin.isEnabled(),
|
||||||
|
origin: plugin
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,12 +1,35 @@
|
|||||||
import { server } from '@ccms/api'
|
import { server } from '@ccms/api'
|
||||||
|
|
||||||
const Sponge = org.spongepowered.api.Sponge
|
const Sponge: typeof org.spongepowered.api.Sponge = Java.type('org.spongepowered.api.Sponge')
|
||||||
|
|
||||||
export class SpongeNativePluginManager extends server.NativePluginManager {
|
export class SpongeNativePluginManager extends server.NativePluginManager {
|
||||||
|
private spongePluginManager: org.spongepowered.api.plugin.PluginManager
|
||||||
|
|
||||||
|
constructor() {
|
||||||
|
super()
|
||||||
|
this.spongePluginManager = Sponge.getPluginManager()
|
||||||
|
}
|
||||||
|
|
||||||
|
list(): server.NativePlugin[] {
|
||||||
|
return Java.from(this.spongePluginManager.getPlugins()).map(plugin => this.convert(plugin))
|
||||||
|
}
|
||||||
has(name: string) {
|
has(name: string) {
|
||||||
return !!this.get(name)
|
return !!this.spongePluginManager.getPlugin(name).orElse(null)
|
||||||
}
|
}
|
||||||
get(name: string) {
|
get(name: string) {
|
||||||
return Sponge.getPluginManager().getPlugin(name).orElse(null)
|
return this.convert(this.spongePluginManager.getPlugin(name).orElse(null))
|
||||||
|
}
|
||||||
|
|
||||||
|
private convert(plugin: org.spongepowered.api.plugin.PluginContainer): server.NativePlugin {
|
||||||
|
if (!plugin) return plugin as any
|
||||||
|
return {
|
||||||
|
name: plugin.getName(),
|
||||||
|
version: plugin.getVersion().get() as string,
|
||||||
|
authors: Java.from(plugin.getAuthors() as string[]),
|
||||||
|
depends: Java.from(plugin.getDependencies()),
|
||||||
|
softDepends: [],
|
||||||
|
enable: true,
|
||||||
|
origin: plugin
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user