Skip to content
This repository was archived by the owner on Dec 10, 2025. It is now read-only.

Commit 19463c1

Browse files
fix: update playtime command to handle asynchronous player retrieval
1 parent 6abd1a8 commit 19463c1

File tree

1 file changed

+8
-4
lines changed
  • surf-cloud-bukkit/src/main/kotlin/dev/slne/surf/cloud/bukkit/command/playtime

1 file changed

+8
-4
lines changed

surf-cloud-bukkit/src/main/kotlin/dev/slne/surf/cloud/bukkit/command/playtime/PlaytimeCommand.kt

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,19 +11,23 @@ import dev.slne.surf.cloud.api.common.player.toCloudPlayer
1111
import dev.slne.surf.cloud.bukkit.permission.CloudPermissionRegistry
1212
import dev.slne.surf.cloud.bukkit.plugin
1313
import dev.slne.surf.surfapi.core.api.messages.adventure.sendText
14+
import kotlinx.coroutines.Deferred
1415
import org.bukkit.command.CommandSender
1516

1617
fun playtimeCommand() = commandTree("playtime") {
1718
withPermission(CloudPermissionRegistry.PLAYTIME_COMMAND)
1819

19-
playerExecutor { sender, args ->
20+
playerExecutor { sender, _ ->
2021
sendPlaytime(sender, sender.toCloudPlayer() ?: throw AssertionError("Player is null"))
2122
}
2223
offlineCloudPlayerArgument("player") {
2324
withPermission(CloudPermissionRegistry.PLAYTIME_COMMAND_OTHER)
2425
anyExecutor { sender, args ->
25-
val player: OfflineCloudPlayer? by args
26-
player?.let { sendPlaytime(sender, it) }
26+
val player: Deferred<OfflineCloudPlayer?> by args
27+
28+
plugin.launch {
29+
player.await()?.let { sendPlaytime(sender, it) }
30+
}
2731
}
2832
}
2933
}
@@ -39,7 +43,7 @@ private fun sendPlaytime(sender: CommandSender, player: OfflineCloudPlayer) = pl
3943
variableValue("${player.name()} (${player.uuid})")
4044
appendNewPrefixedLine()
4145
appendNewPrefixedLine {
42-
variableKey("Total")
46+
variableKey("Gesamt")
4347
spacer(": ")
4448
variableValue(complete.toString())
4549
}

0 commit comments

Comments
 (0)