From 299a8e779162c517ed6f7ef86d315b970ea3a725 Mon Sep 17 00:00:00 2001 From: MiaoWoo Date: Fri, 20 Nov 2020 14:22:28 +0800 Subject: [PATCH] fix: sponge task & command error Signed-off-by: MiaoWoo --- packages/sponge/src/server.ts | 5 ++--- packages/sponge/src/task.ts | 3 +-- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/packages/sponge/src/server.ts b/packages/sponge/src/server.ts index d6622f55..4aeca897 100644 --- a/packages/sponge/src/server.ts +++ b/packages/sponge/src/server.ts @@ -4,7 +4,6 @@ import { provideSingleton } from '@ccms/container' import * as reflect from '@ccms/common/dist/reflect' const Sponge = org.spongepowered.api.Sponge -const TextSerializers = org.spongepowered.api.text.serializer.TextSerializers const File = Java.type("java.io.File") @provideSingleton(server.Server) @@ -35,10 +34,10 @@ export class SpongeServer extends server.ReflectServer { if (typeof sender === 'string') { sender = this.getPlayer(sender) } - return Sponge.getCommandManager().process(sender, command).getSuccessCount().get() != 0 + return Sponge.getCommandManager().process(sender, command).getSuccessCount().orElse(0) != 0 } dispatchConsoleCommand(command: string): boolean { - return Sponge.getCommandManager().process(Sponge.getServer().getConsole(), command).getSuccessCount().get() != 0 + return Sponge.getCommandManager().process(Sponge.getServer().getConsole(), command).getSuccessCount().orElse(0) != 0 } getPluginsFolder(): string { return this.pluginsFolder diff --git a/packages/sponge/src/task.ts b/packages/sponge/src/task.ts index 26c93dd4..25bf7299 100644 --- a/packages/sponge/src/task.ts +++ b/packages/sponge/src/task.ts @@ -20,8 +20,7 @@ export class SpongeTaskManager extends task.TaskManager { return new SpongeTask(owner, func, id) } callSyncMethod(func: Function): any { - // @ts-ignore - return this.syncExecutor.schedule(new Callable({ call: () => func() }), java.lang.Long.valueOf(0), TimeUnit.NANOSECONDS).get() + return this.syncExecutor.execute(() => func()) } disable0() { Sponge.getScheduler().getScheduledTasks(base.getInstance()).forEach((task: task.Cancelable) => task.cancel())