Skip to content

Commit 4da00e4

Browse files
Merge branch 'version/1.21.11' into feat/add-surf-core
2 parents 2347872 + 351e776 commit 4da00e4

File tree

146 files changed

+87871
-56062
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

146 files changed

+87871
-56062
lines changed

build.gradle.kts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar.Companion.shad
22
import kotlinx.validation.KotlinApiBuildTask
33

44
plugins {
5-
id("io.papermc.paperweight.userdev") version "2.0.0-beta.17" apply false
5+
id("io.papermc.paperweight.userdev") version "2.0.0-beta.19" apply false
66
id("org.jetbrains.kotlinx.binary-compatibility-validator") version "0.18.1"
77
// alias(libs.plugins.dokka)
88
}

buildSrc/src/main/kotlin/core-convention.gradle.kts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ dependencies {
2929
compileOnly(libs.auto.service.annotations)
3030
ksp(project(":surf-api-gradle-plugin:surf-api-processor"))
3131

32-
compileOnlyApi("org.jetbrains:annotations:24.1.0")
32+
compileOnlyApi("org.jetbrains:annotations:26.0.2-1")
3333
}
3434

3535
ksp {

gradle.properties

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ kapt.use.k2=true
55
org.gradle.jvmargs=-Xmx4G
66
org.jetbrains.dokka.experimental.gradle.pluginMode=V2Enabled
77
javaVersion=21
8-
mcVersion=1.21.10
8+
mcVersion=1.21.11
99
group=dev.slne.surf
10-
version=1.21.10-2.43.0
10+
version=1.21.11-2.49.1
1111
relocationPrefix=dev.slne.surf.surfapi.libs
12-
snapshot=false
12+
snapshot=false

gradle/libs.versions.toml

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
[versions]
22
# Paper
3-
paper-api = "1.21.10-R0.1-SNAPSHOT"
3+
paper-api = "1.21.11-R0.1-SNAPSHOT"
44

55
# Kolin
6-
kotlinVersion = "2.2.20"
6+
kotlinVersion = "2.3.0"
77
kotlinxCoroutines = "1.10.2"
88
kotlinx-serialization = "1.9.0"
99

1010
# Packet Events
11-
packetevents = "2.10.0"
12-
packetevents-plugin = "2.10.0"
11+
packetevents = "2.11.0"
12+
packetevents-plugin = "2.11.0"
1313

1414
# Command API
1515
commandapi = "11.0.0"
@@ -19,8 +19,8 @@ luckperms = "v5.5.0-bukkit"
1919

2020
# Scoreboard Library
2121
scoreboard-library = "2.4.3"
22-
scoreboard-library-implementation = "2.4.2"
23-
scoreboard-library-modern = "2.4.2"
22+
scoreboard-library-implementation = "2.4.3"
23+
scoreboard-library-modern = "2.4.3"
2424

2525
# Adventure
2626
adventure-api = "4.25.0"
@@ -36,38 +36,38 @@ mccoroutine = "2.22.0"
3636

3737
# Miscellaneous Libraries
3838
guava = "33.5.0-jre"
39-
caffeine = "3.2.1"
40-
caffeine-courotines = "2.0.2"
39+
caffeine = "3.2.3"
40+
caffeine-courotines = "3.0.1"
4141
gson = "2.13.2"
42-
commons-lang3 = "3.19.0"
43-
commons-text = "1.14.0"
42+
commons-lang3 = "3.20.0"
43+
commons-text = "1.15.0"
4444
commons-math4-core = "4.0-beta1"
4545
plugin-yml-paper = "0.8.0"
4646
spongepowered-math = "2.0.1"
4747
fastutil = "8.5.18"
48-
okhttp = "5.1.0"
48+
okhttp = "5.3.2"
4949
dazzleconf = "1.4.0-M1"
5050
reflection-remapper = "0.1.3"
5151
brigadier = "1.0.500"
5252
datafixerupper = "8.0.16"
5353
configurate = "4.2.0"
5454
more-persistent-data-types = "2.4.0"
55-
stefvanschie-if = "0.11.3"
56-
inventory-framework = "3.5.4"
55+
stefvanschie-if = "0.11.6"
56+
inventory-framework = "3.7.1"
5757
flogger = "0.9"
5858
aide-reflection = "1.3"
5959
auto-service = "1.1.1"
6060
auto-service-ksp = "1.2.0"
61-
ktor = "3.3.1"
62-
glm = "0.9.9.1-12"
63-
ksp-version = "2.2.20-2.0.4"
64-
reactor-netty = "1.3.0"
61+
ktor = "3.3.3"
62+
glm = "0.9.9.1-15"
63+
ksp-version = "2.3.3"
64+
reactor-netty = "1.3.1"
6565

6666
# Plugin versions
6767
maven-repo-auth = "3.0.4"
68-
shadow-gradle-plugin = "9.2.2"
69-
run-paper-gradle-plugin = "3.0.1"
70-
dokka = "2.0.0"
68+
shadow-gradle-plugin = "9.3.0"
69+
run-paper-gradle-plugin = "3.0.2"
70+
dokka = "2.1.0"
7171

7272

7373
[libraries]
@@ -187,4 +187,4 @@ ktor-client = ["ktor-client-core", "ktor-client-okhttp", "ktor-client-content-ne
187187
inventory-framework = ["inventory-framework-platform-paper", "inventory-framework-platform-bukkit"]
188188
reactor-netty = ["reactor-netty-core", "reactor-netty-http"]
189189
kotlin-coroutines = ["kotlinxCoroutines-core", "kotlinxCoroutines-reactor", "kotlinxCoroutines-reactive"]
190-
kotlin-serialization = ["kotlin-serialization-json", "kotlin-serialization-protobuf"]
190+
kotlin-serialization = ["kotlin-serialization-json", "kotlin-serialization-protobuf"]

surf-api-bukkit/surf-api-bukkit-api/api/surf-api-bukkit-api.api

Lines changed: 5340 additions & 5556 deletions
Large diffs are not rendered by default.
Lines changed: 106 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,106 @@
1+
package dev.slne.surf.surfapi.bukkit.api.command.args
2+
3+
import com.github.shynixn.mccoroutine.folia.SuspendingPlugin
4+
import com.github.shynixn.mccoroutine.folia.scope
5+
import com.mojang.brigadier.context.CommandContext
6+
import dev.jorel.commandapi.CommandAPIBukkit
7+
import dev.jorel.commandapi.CommandAPIHandler
8+
import dev.jorel.commandapi.arguments.Argument
9+
import dev.jorel.commandapi.arguments.CustomArgument
10+
import dev.jorel.commandapi.executors.CommandArguments
11+
import dev.slne.surf.surfapi.bukkit.api.util.getCallingPlugin
12+
import kotlinx.coroutines.CoroutineScope
13+
import kotlinx.coroutines.Deferred
14+
import kotlinx.coroutines.async
15+
16+
/**
17+
* Base class for custom CommandAPI arguments whose parsing logic is executed asynchronously
18+
* using Kotlin coroutines.
19+
*
20+
* This abstraction allows implementing suspendable parsing logic while still integrating
21+
* with CommandAPI's synchronous argument parsing pipeline by returning a [Deferred].
22+
*
23+
* @param T The final parsed argument type.
24+
* @param B The base argument type produced by the underlying [Argument].
25+
* @property base The underlying base argument used for initial parsing.
26+
* @property scope The [CoroutineScope] used to execute the suspendable parsing logic.
27+
*/
28+
abstract class SuspendCustomArgument<T, B>(
29+
private val base: Argument<B>,
30+
private val scope: CoroutineScope = extractCallingPluginScopeOrThrow()
31+
) : CustomArgument<Deferred<T>, B>(base, { _ ->
32+
throw UnsupportedOperationException("Parsing is performed asynchronously via the overridden parse method")
33+
}) {
34+
35+
/**
36+
* Parses the argument asynchronously.
37+
*
38+
* This method is executed inside the provided [CoroutineScope] and may perform
39+
* suspendable or asynchronous operations such as database lookups or network calls.
40+
*
41+
* Implementations should throw [CustomArgumentException] to signal a user-facing
42+
* parsing error.
43+
*
44+
* @param info Contextual information about the argument being parsed.
45+
* @return The parsed argument value.
46+
* @throws CustomArgumentException If parsing fails with a user-facing error.
47+
*/
48+
abstract suspend fun CoroutineScope.parse(info: CustomArgumentInfo<B>): T
49+
50+
/**
51+
* Synchronously invoked by CommandAPI to parse the argument.
52+
*
53+
* Internally, this method delegates to [parse] by launching a coroutine in [scope]
54+
* and returning a [Deferred] representing the eventual parsing result.
55+
*
56+
* Any thrown [CustomArgumentException] is converted into a Brigadier
57+
* [com.mojang.brigadier.exceptions.CommandSyntaxException].
58+
*
59+
* @param cmdCtx The Brigadier command context.
60+
* @param key The argument node name.
61+
* @param previousArgs Previously parsed command arguments.
62+
* @return A [Deferred] that completes with the parsed argument value.
63+
*/
64+
final override fun <CommandSourceStack : Any> parseArgument(
65+
cmdCtx: CommandContext<CommandSourceStack>,
66+
key: String,
67+
previousArgs: CommandArguments
68+
): Deferred<T> {
69+
val customResult = CommandAPIHandler.getRawArgumentInput(cmdCtx, key)
70+
val parsedInput = base.parseArgument(cmdCtx, key, previousArgs)
71+
72+
return scope.async {
73+
try {
74+
val sender = CommandAPIBukkit.get<CommandSourceStack>()
75+
.getCommandSenderFromCommandSource(cmdCtx.source).source
76+
val info = CustomArgumentInfo(sender, previousArgs, customResult, parsedInput)
77+
parse(info)
78+
} catch (e: CustomArgumentException) {
79+
throw e.toCommandSyntax(customResult, cmdCtx)
80+
}
81+
}
82+
}
83+
84+
companion object {
85+
/**
86+
* Extracts the [CoroutineScope] of the calling plugin.
87+
*
88+
* The calling plugin must implement [SuspendingPlugin]. If it does not,
89+
* an exception is thrown to prevent executing coroutines without
90+
* proper lifecycle management.
91+
*
92+
* @return The plugin's coroutine scope.
93+
* @throws IllegalArgumentException If the plugin does not implement [SuspendingPlugin].
94+
*/
95+
private fun extractCallingPluginScopeOrThrow(): CoroutineScope {
96+
val plugin = getCallingPlugin(2)
97+
98+
require(plugin is SuspendingPlugin) {
99+
"Failed to extract CoroutineScope: plugin '${plugin.name}' does not implement SuspendingPlugin. " +
100+
"Provide a CoroutineScope explicitly or use a SuspendingPlugin."
101+
}
102+
103+
return plugin.scope
104+
}
105+
}
106+
}

0 commit comments

Comments
 (0)