fix: sponge task & command error

Signed-off-by: MiaoWoo <admin@yumc.pw>
This commit is contained in:
MiaoWoo 2020-11-20 14:22:28 +08:00
parent af1e64767a
commit 299a8e7791
2 changed files with 3 additions and 5 deletions

View File

@ -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

View File

@ -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())