From 0fea6b55373a40b395859e2262b5e81b849e69c6 Mon Sep 17 00:00:00 2001 From: MiaoWoo Date: Fri, 2 Oct 2020 16:43:18 +0800 Subject: [PATCH] fix: server method error Signed-off-by: MiaoWoo --- packages/bukkit/src/server.ts | 4 ++-- packages/nukkit/src/server.ts | 21 +++++++++------------ 2 files changed, 11 insertions(+), 14 deletions(-) diff --git a/packages/bukkit/src/server.ts b/packages/bukkit/src/server.ts index 2ca58056..4fef8586 100644 --- a/packages/bukkit/src/server.ts +++ b/packages/bukkit/src/server.ts @@ -16,13 +16,13 @@ export class BukkitServer extends server.ReflectServer { } getPlayer(name: string) { - return Bukkit.getPlayer(name) + return Bukkit.getPlayerExact(name) } getVersion(): string { return Bukkit.getVersion() } getOnlinePlayers() { - return Bukkit.getOnlinePlayers() as unknown as any[] + return Bukkit.getOnlinePlayers() } getConsoleSender() { return Bukkit.getConsoleSender() diff --git a/packages/nukkit/src/server.ts b/packages/nukkit/src/server.ts index d73a759c..dea99d1f 100644 --- a/packages/nukkit/src/server.ts +++ b/packages/nukkit/src/server.ts @@ -1,25 +1,25 @@ import { server } from '@ccms/api' -import { provideSingleton } from '@ccms/container'; +import { provideSingleton } from '@ccms/container' -let Nukkit: cn.nukkit.Server = base.getInstance().getServer(); -const File = Java.type("java.io.File"); +let Nukkit: cn.nukkit.Server = base.getInstance().getServer() +const File = Java.type("java.io.File") @provideSingleton(server.Server) export class NukkitServer implements server.Server { - private pluginsFolder: string; + private pluginsFolder: string constructor() { this.pluginsFolder = new File(base.getInstance().getClass().getProtectionDomain().getCodeSource().getLocation().getPath()).getParentFile().getCanonicalPath() } getPlayer(name: string) { - return Nukkit.getPlayer(name) + return Nukkit.getPlayerExact(name) } getVersion(): string { return Nukkit.getVersion() } getOnlinePlayers() { - return Nukkit.getOnlinePlayers() as unknown as any[] + return Nukkit.getOnlinePlayers().values() } getConsoleSender() { return Nukkit.getConsoleSender() @@ -37,18 +37,15 @@ export class NukkitServer implements server.Server { return Nukkit.dispatchCommand(Nukkit.getConsoleSender(), command) } getPluginsFolder(): string { - return this.pluginsFolder; + return this.pluginsFolder } getNativePluginManager() { - return Nukkit.getPluginManager() as any; + return Nukkit.getPluginManager() as any } getNettyPipeline() { - throw new Error("Method not implemented."); + throw new Error("Method not implemented.") } getRootLogger() { return Packages.org.apache.logging.log4j.LogManager.getRootLogger() } - sendJson(sender: string | any, json: object | string): void { - throw new Error("Method not implemented."); - } }