From 6696cb4845c028b9d9879f6a9c626064642e5286 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sat, 24 Jan 2026 22:30:41 +0000 Subject: [PATCH 1/4] Initial plan From ab40e39a214bb3dd2e8126d5354af37df46209d0 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sat, 24 Jan 2026 22:36:21 +0000 Subject: [PATCH 2/4] Extract PluginHookMeta to surf-api-common shared module Co-authored-by: twisti-dev <76837088+twisti-dev@users.noreply.github.com> --- settings.gradle.kts | 1 + surf-api-common/build.gradle.kts | 24 +++++++++++++++++++ .../surfapi/common}/hook/PluginHookMeta.kt | 4 ++-- .../surf-api-core-server/build.gradle.kts | 1 + .../surfapi/core/server/hook/HookService.kt | 1 + .../core/server/hook/PluginHookMeta.kt | 20 ---------------- .../surf-api-processor/build.gradle.kts | 1 + .../processor/hook/HookSymbolProcessor.kt | 1 + 8 files changed, 31 insertions(+), 22 deletions(-) create mode 100644 surf-api-common/build.gradle.kts rename {surf-api-gradle-plugin/surf-api-processor/src/main/kotlin/dev/slne/surf/surfapi/processor => surf-api-common/src/main/kotlin/dev/slne/surf/surfapi/common}/hook/PluginHookMeta.kt (90%) delete mode 100644 surf-api-core/surf-api-core-server/src/main/kotlin/dev/slne/surf/surfapi/core/server/hook/PluginHookMeta.kt diff --git a/settings.gradle.kts b/settings.gradle.kts index 49471d0f..93c19110 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -24,6 +24,7 @@ include(":surf-api-velocity:surf-api-velocity-api") include(":surf-api-velocity:surf-api-velocity-server") include("surf-api-standalone") +include("surf-api-common") include("surf-api-gradle-plugin") include("surf-api-gradle-plugin:surf-api-processor") diff --git a/surf-api-common/build.gradle.kts b/surf-api-common/build.gradle.kts new file mode 100644 index 00000000..bfee9752 --- /dev/null +++ b/surf-api-common/build.gradle.kts @@ -0,0 +1,24 @@ +// region properties +val mcVersion: String by project +val groupId = findProperty("group") as String +val snapshot = (findProperty("snapshot") as String).toBooleanStrict() +// endregion + +plugins { + kotlin("jvm") + kotlin("plugin.serialization") + `publish-convention` +} + +group = groupId +version = buildString { + append(mcVersion) + append("-1.0.0") + if (snapshot) append("-SNAPSHOT") +} + +dependencies { + implementation(libs.kotlin.serialization.json) +} + +description = "surf-api-common" diff --git a/surf-api-gradle-plugin/surf-api-processor/src/main/kotlin/dev/slne/surf/surfapi/processor/hook/PluginHookMeta.kt b/surf-api-common/src/main/kotlin/dev/slne/surf/surfapi/common/hook/PluginHookMeta.kt similarity index 90% rename from surf-api-gradle-plugin/surf-api-processor/src/main/kotlin/dev/slne/surf/surfapi/processor/hook/PluginHookMeta.kt rename to surf-api-common/src/main/kotlin/dev/slne/surf/surfapi/common/hook/PluginHookMeta.kt index 047bd414..12c9bb0e 100644 --- a/surf-api-gradle-plugin/surf-api-processor/src/main/kotlin/dev/slne/surf/surfapi/processor/hook/PluginHookMeta.kt +++ b/surf-api-common/src/main/kotlin/dev/slne/surf/surfapi/common/hook/PluginHookMeta.kt @@ -1,4 +1,4 @@ -package dev.slne.surf.surfapi.processor.hook +package dev.slne.surf.surfapi.common.hook import kotlinx.serialization.Serializable @@ -17,4 +17,4 @@ data class PluginHookMeta(val hooks: List) { companion object { fun empty() = PluginHookMeta(emptyList()) } -} \ No newline at end of file +} diff --git a/surf-api-core/surf-api-core-server/build.gradle.kts b/surf-api-core/surf-api-core-server/build.gradle.kts index 97f09634..6d76f9f8 100644 --- a/surf-api-core/surf-api-core-server/build.gradle.kts +++ b/surf-api-core/surf-api-core-server/build.gradle.kts @@ -4,6 +4,7 @@ plugins { dependencies { api(project(":surf-api-core:surf-api-core-api")) + implementation(project(":surf-api-common")) compileOnly(libs.packetevents.netty.common) } diff --git a/surf-api-core/surf-api-core-server/src/main/kotlin/dev/slne/surf/surfapi/core/server/hook/HookService.kt b/surf-api-core/surf-api-core-server/src/main/kotlin/dev/slne/surf/surfapi/core/server/hook/HookService.kt index 60c3656b..6403d717 100644 --- a/surf-api-core/surf-api-core-server/src/main/kotlin/dev/slne/surf/surfapi/core/server/hook/HookService.kt +++ b/surf-api-core/surf-api-core-server/src/main/kotlin/dev/slne/surf/surfapi/core/server/hook/HookService.kt @@ -1,6 +1,7 @@ package dev.slne.surf.surfapi.core.server.hook import com.github.benmanes.caffeine.cache.Caffeine +import dev.slne.surf.surfapi.common.hook.PluginHookMeta import dev.slne.surf.surfapi.core.api.hook.AbstractHook import dev.slne.surf.surfapi.core.api.util.mutableObject2ObjectMapOf import dev.slne.surf.surfapi.core.api.util.mutableObjectListOf diff --git a/surf-api-core/surf-api-core-server/src/main/kotlin/dev/slne/surf/surfapi/core/server/hook/PluginHookMeta.kt b/surf-api-core/surf-api-core-server/src/main/kotlin/dev/slne/surf/surfapi/core/server/hook/PluginHookMeta.kt deleted file mode 100644 index 8d9fdccb..00000000 --- a/surf-api-core/surf-api-core-server/src/main/kotlin/dev/slne/surf/surfapi/core/server/hook/PluginHookMeta.kt +++ /dev/null @@ -1,20 +0,0 @@ -package dev.slne.surf.surfapi.core.server.hook - -import kotlinx.serialization.Serializable - -@Serializable -data class PluginHookMeta(val hooks: List) { - - @Serializable - data class Hook( - val priority: Short, - val className: String, - val classDependencies: List, - val pluginDependencies: List, - val pluginOneDependencies: List>, - ) - - companion object { - fun empty() = PluginHookMeta(emptyList()) - } -} \ No newline at end of file diff --git a/surf-api-gradle-plugin/surf-api-processor/build.gradle.kts b/surf-api-gradle-plugin/surf-api-processor/build.gradle.kts index b37faec9..984be39c 100644 --- a/surf-api-gradle-plugin/surf-api-processor/build.gradle.kts +++ b/surf-api-gradle-plugin/surf-api-processor/build.gradle.kts @@ -18,6 +18,7 @@ version = buildString { } dependencies { + implementation(project(":surf-api-common")) implementation(libs.ksp.api) implementation(libs.auto.service.annotations) implementation(libs.kotlin.serialization.json) diff --git a/surf-api-gradle-plugin/surf-api-processor/src/main/kotlin/dev/slne/surf/surfapi/processor/hook/HookSymbolProcessor.kt b/surf-api-gradle-plugin/surf-api-processor/src/main/kotlin/dev/slne/surf/surfapi/processor/hook/HookSymbolProcessor.kt index fb24a0b6..41eca1af 100644 --- a/surf-api-gradle-plugin/surf-api-processor/src/main/kotlin/dev/slne/surf/surfapi/processor/hook/HookSymbolProcessor.kt +++ b/surf-api-gradle-plugin/surf-api-processor/src/main/kotlin/dev/slne/surf/surfapi/processor/hook/HookSymbolProcessor.kt @@ -9,6 +9,7 @@ import com.google.devtools.ksp.symbol.KSAnnotated import com.google.devtools.ksp.symbol.KSAnnotation import com.google.devtools.ksp.symbol.KSClassDeclaration import com.google.devtools.ksp.symbol.KSType +import dev.slne.surf.surfapi.common.hook.PluginHookMeta import dev.slne.surf.surfapi.processor.util.toBinaryName import kotlinx.serialization.json.Json import java.io.IOException From 91af80189d82d2ea5a11bd8b5d694a09d4a57d1e Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sat, 24 Jan 2026 22:37:10 +0000 Subject: [PATCH 3/4] Add README documenting surf-api-common module purpose Co-authored-by: twisti-dev <76837088+twisti-dev@users.noreply.github.com> --- surf-api-common/README.md | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 surf-api-common/README.md diff --git a/surf-api-common/README.md b/surf-api-common/README.md new file mode 100644 index 00000000..864602c2 --- /dev/null +++ b/surf-api-common/README.md @@ -0,0 +1,27 @@ +# surf-api-common + +This module contains common data structures and models that are shared between multiple surf-api modules, particularly between the annotation processor (surf-api-processor) and the runtime modules (surf-api-core). + +## Purpose + +The primary purpose of this module is to provide a single source of truth for data structures that are used for serialization contracts between compile-time processing and runtime execution. This prevents schema drift and runtime decode failures that could occur when maintaining duplicate copies of the same data structures in different modules. + +## Current Contents + +### Hook Metadata (`dev.slne.surf.surfapi.common.hook`) + +- **PluginHookMeta**: Data class representing the metadata for plugin hooks, serialized to `surf-hooks.json` by the annotation processor and read at runtime by the hook service. + +## Usage + +This module is automatically included as a dependency in: +- `surf-api-processor` (for generating metadata during compilation) +- `surf-api-core-server` (for reading metadata at runtime) + +## Adding New Common Structures + +When you need to add a new data structure that must be shared between the processor and runtime: + +1. Add the class to an appropriate package under `dev.slne.surf.surfapi.common` +2. Annotate it with `@Serializable` if it needs to be serialized/deserialized +3. Update the modules that need to use it to depend on `surf-api-common` From 3004d7a0f0245a1205790aa400aa298dade49a9d Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sat, 24 Jan 2026 22:37:58 +0000 Subject: [PATCH 4/4] Fix formatting: remove trailing blank line Co-authored-by: twisti-dev <76837088+twisti-dev@users.noreply.github.com> --- .../kotlin/dev/slne/surf/surfapi/common/hook/PluginHookMeta.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/surf-api-common/src/main/kotlin/dev/slne/surf/surfapi/common/hook/PluginHookMeta.kt b/surf-api-common/src/main/kotlin/dev/slne/surf/surfapi/common/hook/PluginHookMeta.kt index 12c9bb0e..7b07d9b3 100644 --- a/surf-api-common/src/main/kotlin/dev/slne/surf/surfapi/common/hook/PluginHookMeta.kt +++ b/surf-api-common/src/main/kotlin/dev/slne/surf/surfapi/common/hook/PluginHookMeta.kt @@ -17,4 +17,4 @@ data class PluginHookMeta(val hooks: List) { companion object { fun empty() = PluginHookMeta(emptyList()) } -} +} \ No newline at end of file