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

Commit 0831ea5

Browse files
committed
refactor: replace AsyncOfflinePlayerArgument with AsyncPlayerProfileArgument and clean up unused logic
- Switched to `AsyncPlayerProfileArgument` in `OfflineCloudPlayerArgument` for improved argument handling. - Updated conversion logic to utilize `PlayerProfile` with `.toOfflineCloudPlayer()`. - Removed unused `test` method and cleaned up player-related logic in `BukkitClientCloudPlayerImpl`. - Simplified cache handling with `StreamCodec.composite`. - Replaced `CommandAPIBukkit` method with `CommandAPIPaper` for better Paper API integration. - Removed unused KSP-related Gradle properties.
1 parent 76b24e5 commit 0831ea5

File tree

6 files changed

+13
-61
lines changed

6 files changed

+13
-61
lines changed

gradle.properties

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,3 @@ kotlin.code.style=official
66
org.jetbrains.dokka.experimental.gradle.pluginMode=V2Enabled
77
org.jetbrains.dokka.experimental.gradle.pluginMode.noWarn=true
88
version=1.21.10-1.0.0-SNAPSHOT
9-
ksp.incremental=false
10-
ksp.incremental.log=true
11-
ksp.useKSP2=false

surf-cloud-api/surf-cloud-api-client/surf-cloud-api-client-paper/src/main/kotlin/dev/slne/surf/cloud/api/client/paper/command/args/OfflineCloudPlayerArgument.kt

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,30 @@
11
package dev.slne.surf.cloud.api.client.paper.command.args
22

3+
import com.destroystokyo.paper.profile.PlayerProfile
34
import dev.jorel.commandapi.CommandAPICommand
45
import dev.jorel.commandapi.CommandTree
56
import dev.jorel.commandapi.arguments.Argument
67
import dev.jorel.commandapi.arguments.ArgumentSuggestions
7-
import dev.jorel.commandapi.arguments.AsyncOfflinePlayerArgument
8+
import dev.jorel.commandapi.arguments.AsyncPlayerProfileArgument
89
import dev.jorel.commandapi.arguments.CustomArgument
9-
import dev.slne.surf.cloud.api.client.paper.player.toCloudOfflinePlayer
1010
import dev.slne.surf.cloud.api.common.player.CloudPlayerManager
1111
import dev.slne.surf.cloud.api.common.player.OfflineCloudPlayer
12+
import dev.slne.surf.cloud.api.common.player.toOfflineCloudPlayer
1213
import dev.slne.surf.surfapi.core.api.messages.adventure.sendText
1314
import dev.slne.surf.surfapi.core.api.util.logger
1415
import kotlinx.coroutines.*
1516
import kotlinx.coroutines.future.await
1617
import kotlinx.coroutines.future.future
17-
import org.bukkit.OfflinePlayer
1818
import java.util.concurrent.CompletableFuture
1919

2020
class OfflineCloudPlayerArgument(nodeName: String) :
21-
CustomArgument<Deferred<OfflineCloudPlayer?>, CompletableFuture<OfflinePlayer>>(
22-
AsyncOfflinePlayerArgument(nodeName),
21+
CustomArgument<Deferred<OfflineCloudPlayer?>, CompletableFuture<List<PlayerProfile>>>(
22+
AsyncPlayerProfileArgument(nodeName),
2323
{ info ->
2424
scope.async {
2525
try {
26-
val player = info.currentInput.await()
27-
player.toCloudOfflinePlayer()
26+
val profile = info.currentInput.await().firstOrNull()
27+
profile?.id?.toOfflineCloudPlayer()
2828
} catch (e: RuntimeException) {
2929
val cause = e.cause
3030
val rootCause = if (cause is RuntimeException) cause.cause else cause

surf-cloud-bukkit/src/main/kotlin/dev/slne/surf/cloud/bukkit/PaperMain.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ package dev.slne.surf.cloud.bukkit
22

33
import com.github.shynixn.mccoroutine.folia.SuspendingJavaPlugin
44
import com.github.shynixn.mccoroutine.folia.launch
5-
import dev.jorel.commandapi.CommandAPIBukkit
5+
import dev.jorel.commandapi.CommandAPIPaper
66
import dev.jorel.commandapi.kotlindsl.*
77
import dev.slne.surf.cloud.api.client.netty.packet.fireAndForget
88
import dev.slne.surf.cloud.api.common.TestPacket
@@ -117,7 +117,7 @@ class PaperMain : SuspendingJavaPlugin() {
117117
}
118118

119119
private fun failCommand(message: () -> Component): Nothing { // TODO: 20.01.2025 20:51 - move to surf-api
120-
throw CommandAPIBukkit.failWithAdventureComponent(message)
120+
throw CommandAPIPaper.failWithAdventureComponent(message)
121121
}
122122

123123
override suspend fun onDisableAsync() {

surf-cloud-bukkit/src/main/kotlin/dev/slne/surf/cloud/bukkit/player/BukkitClientCloudPlayerImpl.kt

Lines changed: 2 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -8,18 +8,17 @@ import dev.slne.surf.cloud.api.common.player.teleport.TeleportCause
88
import dev.slne.surf.cloud.api.common.player.teleport.TeleportFlag
99
import dev.slne.surf.cloud.api.common.player.teleport.WorldLocation
1010
import dev.slne.surf.cloud.bukkit.listener.player.SilentDisconnectListener
11-
import dev.slne.surf.cloud.bukkit.plugin
1211
import dev.slne.surf.cloud.core.client.player.ClientCloudPlayerImpl
1312
import dev.slne.surf.cloud.core.common.netty.network.protocol.running.DisconnectPlayerPacket
1413
import dev.slne.surf.cloud.core.common.netty.network.protocol.running.SilentDisconnectPlayerPacket
1514
import kotlinx.coroutines.future.await
1615
import net.kyori.adventure.text.Component
1716
import org.bukkit.Bukkit
18-
import org.bukkit.conversations.*
1917
import org.bukkit.entity.Player
2018
import java.util.*
2119

22-
class BukkitClientCloudPlayerImpl(uuid: UUID, name: String) : ClientCloudPlayerImpl<Player>(uuid,
20+
class BukkitClientCloudPlayerImpl(uuid: UUID, name: String) : ClientCloudPlayerImpl<Player>(
21+
uuid,
2322
name
2423
) {
2524
public override val audience: Player? get() = Bukkit.getPlayer(uuid)
@@ -35,52 +34,6 @@ class BukkitClientCloudPlayerImpl(uuid: UUID, name: String) : ClientCloudPlayerI
3534
)
3635
}
3736

38-
fun test() {
39-
val player = audience ?: return
40-
41-
val factory = ConversationFactory(plugin)
42-
factory.withModality(true) // player doesn't receive messages from other players
43-
factory.withLocalEcho(false) // player doesn't see their own messages
44-
factory.withPrefix { ">> " } // prefix for messages
45-
factory.withTimeout(60) // timeout in seconds
46-
factory.withEscapeSequence("exit") // escape sequence to exit conversation
47-
val secondQuestion = object : NumericPrompt() {
48-
override fun acceptValidatedInput(
49-
context: ConversationContext,
50-
input: Number
51-
): Prompt? {
52-
// process input
53-
54-
return null // next prompt
55-
}
56-
57-
override fun getPromptText(context: ConversationContext): String {
58-
return "Enter a number"
59-
}
60-
}
61-
62-
val firstQuestion = object : BooleanPrompt() {
63-
64-
override fun acceptValidatedInput(
65-
context: ConversationContext,
66-
input: Boolean
67-
): Prompt? {
68-
// process input
69-
70-
return secondQuestion // next prompt
71-
}
72-
73-
override fun getPromptText(context: ConversationContext): String {
74-
return "Do you want to continue?"
75-
}
76-
}
77-
78-
factory.withFirstPrompt(firstQuestion)
79-
80-
val conversation = factory.buildConversation(player)
81-
conversation.begin()
82-
}
83-
8437
override suspend fun teleport(
8538
location: WorldLocation,
8639
teleportCause: TeleportCause,

surf-cloud-core/surf-cloud-core-common/src/main/kotlin/dev/slne/surf/cloud/core/common/netty/network/protocol/running/ClientboundCacheDeltaPacket.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package dev.slne.surf.cloud.core.common.netty.network.protocol.running
33
import dev.slne.surf.cloud.api.common.meta.SurfNettyPacket
44
import dev.slne.surf.cloud.api.common.netty.network.codec.ByteBufCodecs
55
import dev.slne.surf.cloud.api.common.netty.network.codec.StreamCodec
6+
import dev.slne.surf.cloud.api.common.netty.network.codec.composite
67
import dev.slne.surf.cloud.api.common.netty.network.protocol.PacketFlow
78
import dev.slne.surf.cloud.api.common.netty.packet.NettyPacket
89
import dev.slne.surf.cloud.api.common.player.cache.key.CacheNetworkKey

surf-cloud-core/surf-cloud-core-common/src/main/kotlin/dev/slne/surf/cloud/core/common/netty/network/protocol/running/ServerboundCacheOpPacket.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package dev.slne.surf.cloud.core.common.netty.network.protocol.running
33
import dev.slne.surf.cloud.api.common.meta.SurfNettyPacket
44
import dev.slne.surf.cloud.api.common.netty.network.codec.ByteBufCodecs
55
import dev.slne.surf.cloud.api.common.netty.network.codec.StreamCodec
6+
import dev.slne.surf.cloud.api.common.netty.network.codec.composite
67
import dev.slne.surf.cloud.api.common.netty.network.protocol.PacketFlow
78
import dev.slne.surf.cloud.api.common.netty.packet.NettyPacket
89
import dev.slne.surf.cloud.api.common.player.cache.key.CacheNetworkKey

0 commit comments

Comments
 (0)