From 19463c108c9083f79b9e849cf73b3fdca78d3028 Mon Sep 17 00:00:00 2001 From: TheBjoRedCraft Date: Thu, 20 Nov 2025 19:28:12 +0100 Subject: [PATCH] fix: update playtime command to handle asynchronous player retrieval --- .../cloud/bukkit/command/playtime/PlaytimeCommand.kt | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/surf-cloud-bukkit/src/main/kotlin/dev/slne/surf/cloud/bukkit/command/playtime/PlaytimeCommand.kt b/surf-cloud-bukkit/src/main/kotlin/dev/slne/surf/cloud/bukkit/command/playtime/PlaytimeCommand.kt index b4eb15e9..1325bea2 100644 --- a/surf-cloud-bukkit/src/main/kotlin/dev/slne/surf/cloud/bukkit/command/playtime/PlaytimeCommand.kt +++ b/surf-cloud-bukkit/src/main/kotlin/dev/slne/surf/cloud/bukkit/command/playtime/PlaytimeCommand.kt @@ -11,19 +11,23 @@ import dev.slne.surf.cloud.api.common.player.toCloudPlayer import dev.slne.surf.cloud.bukkit.permission.CloudPermissionRegistry import dev.slne.surf.cloud.bukkit.plugin import dev.slne.surf.surfapi.core.api.messages.adventure.sendText +import kotlinx.coroutines.Deferred import org.bukkit.command.CommandSender fun playtimeCommand() = commandTree("playtime") { withPermission(CloudPermissionRegistry.PLAYTIME_COMMAND) - playerExecutor { sender, args -> + playerExecutor { sender, _ -> sendPlaytime(sender, sender.toCloudPlayer() ?: throw AssertionError("Player is null")) } offlineCloudPlayerArgument("player") { withPermission(CloudPermissionRegistry.PLAYTIME_COMMAND_OTHER) anyExecutor { sender, args -> - val player: OfflineCloudPlayer? by args - player?.let { sendPlaytime(sender, it) } + val player: Deferred by args + + plugin.launch { + player.await()?.let { sendPlaytime(sender, it) } + } } } } @@ -39,7 +43,7 @@ private fun sendPlaytime(sender: CommandSender, player: OfflineCloudPlayer) = pl variableValue("${player.name()} (${player.uuid})") appendNewPrefixedLine() appendNewPrefixedLine { - variableKey("Total") + variableKey("Gesamt") spacer(": ") variableValue(complete.toString()) }