You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: .github/copilot-instructions.md
+50-25Lines changed: 50 additions & 25 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -16,26 +16,38 @@
16
16
./gradlew publishToMavenLocal
17
17
```
18
18
19
-
CI uses **Java 25 GraalVM**. The Java toolchain version is set in `gradle.properties` (`javaVersion=25`).
19
+
CI uses **Java 25 GraalVM**. The Java toolchain version is set in `gradle.properties` (
20
+
`javaVersion=25`).
20
21
21
22
## Architecture
22
23
23
-
**Multi-platform Minecraft server API** — Kotlin on JVM, targeting Paper/Bukkit, Velocity, and Standalone (Hytale is future/placeholder). Every platform follows an **API/Implementation split**:
24
+
**Multi-platform Minecraft server API** — Kotlin on JVM, targeting Paper/Bukkit, Velocity, and
25
+
Standalone (Hytale is future/placeholder). Every platform follows an **API/Implementation split**:
24
26
25
27
-`-api` modules define public interfaces and extension functions (what consumers depend on)
26
28
-`-server` modules contain implementations (shaded into the final JAR, not published as API)
27
29
-`surf-api-shared` contains cross-platform annotations, the component system, and internal hooks
28
-
-`surf-api-gradle-plugin` provides Gradle plugins (`dev.slne.surf.surfapi.gradle.paper-plugin`, etc.) that downstream projects apply, and contains the KSP symbol processor (`surf-api-processor`)
that downstream projects apply, and contains the KSP symbol processor (`surf-api-processor`)
29
32
30
33
### Service Discovery (two mechanisms)
31
34
32
-
1.**`requiredService<T>()`** — For singleton bridges/APIs. Uses Adventure's `Services.serviceWithFallback()` backed by Java `ServiceLoader`. Implementations register with `@AutoService(InterfaceName::class)`. Used for NMS bridges, platform API singletons, and core services.
35
+
1.**`requiredService<T>()`** — For singleton bridges/APIs. Uses Adventure's
36
+
`Services.serviceWithFallback()` backed by Java `ServiceLoader`. Implementations register with
37
+
`@AutoService(InterfaceName::class)`. Used for NMS bridges, platform API singletons, and core
38
+
services.
33
39
34
-
2.**Component System** — For lifecycle-managed components. Classes annotated with `@ComponentMeta` (or meta-annotations `@Service`, `@Repository`) are discovered at compile-time by KSP, which writes JSON metadata to `META-INF/surfapi/components/`. At runtime, `ComponentService` loads, topologically sorts by `@Priority` and `@DependsOnComponent`, checks conditions (`@ConditionalOnProperty`, `@DependsOnPlugin`, `@DependsOnClass`, etc.), then calls `suspend fun load()` → `enable()` → `disable()`.
40
+
2.**Component System** — For lifecycle-managed components. Classes annotated with
41
+
`@ComponentMeta` (or meta-annotations `@Service`, `@Repository`) are discovered at compile-time
42
+
by KSP, which writes JSON metadata to `META-INF/surfapi/components/`. At runtime,
43
+
`ComponentService` loads, topologically sorts by `@Priority` and `@DependsOnComponent`, checks
44
+
conditions (`@ConditionalOnProperty`, `@DependsOnPlugin`, `@DependsOnClass`, etc.), then calls
45
+
`suspend fun load()` → `enable()` → `disable()`.
35
46
36
47
### NMS Bridge Pattern
37
48
38
-
Platform-specific (NMS) code is abstracted behind bridge interfaces in `-api` with implementations in `-server`:
49
+
Platform-specific (NMS) code is abstracted behind bridge interfaces in `-api` with implementations
50
+
in `-server`:
39
51
40
52
```kotlin
41
53
// In -api: interface + companion delegation
@@ -56,15 +68,20 @@ Bridge implementations call `checkInstantiationByServiceLoader()` in their `init
56
68
57
69
### Kotlin Features
58
70
59
-
-**Context parameters** enabled globally (`-Xcontext-parameters`). Used extensively in inventory framework DSLs:
71
+
-**Context parameters** enabled globally (`-Xcontext-parameters`). Used extensively in inventory
72
+
framework DSLs:
60
73
```kotlin
61
74
context(ctx:AbstractSurfViewContext<ViewRef>)
62
75
fun <ViewRef:AbstractSurfViewRef> onOpen(block: context(ViewRef) OpenContext.() ->Unit)
63
76
```
64
-
-**`@InternalSurfApi`** — `@RequiresOptIn` annotation for internal APIs. All subprojects opt in via compiler args. Mark new internal APIs with this.
65
-
-**Coroutines** for all async work. Component lifecycle methods are `suspend`. Bukkit uses MCCoroutine (Folia-aware) for dispatching.
66
-
-**Extension functions** are the primary API enrichment pattern, organized in files named `*-extension.kt` or `*-extensions.kt`.
67
-
-**DSL markers** (`@InventoryFrameworkDSL`, `@ItemDsl`, `@PaneMarker`) restrict scope in builder DSLs.
77
+
-**`@InternalSurfApi`** — `@RequiresOptIn` annotation for internal APIs. All subprojects opt in via
78
+
compiler args. Mark new internal APIs with this.
79
+
-**Coroutines** for all async work. Component lifecycle methods are `suspend`. Bukkit uses
80
+
MCCoroutine (Folia-aware) for dispatching.
81
+
-**Extension functions** are the primary API enrichment pattern, organized in files named
82
+
`*-extension.kt` or `*-extensions.kt`.
83
+
-**DSL markers** (`@InventoryFrameworkDSL`, `@ItemDsl`, `@PaneMarker`) restrict scope in builder
84
+
DSLs.
68
85
69
86
### Logging
70
87
@@ -78,33 +95,41 @@ log.atWarning().withCause(e).log("Failed to do X for %s", name)
78
95
### Package Structure
79
96
80
97
```
81
-
dev.slne.surf.surfapi # root
82
-
dev.slne.surf.surfapi.core.api # core API interfaces
dev.slne.surf.api.shared.api # shared annotations and component system
105
+
dev.slne.surf.api.libs.* # relocation target for shaded deps
89
106
```
90
107
91
108
### Dependency Shading
92
109
93
-
All non-platform dependencies are shaded via Shadow and relocated to `dev.slne.surf.surfapi.libs.*` (configured in `gradle.properties` as `relocationPrefix`). Platform APIs (Paper, Velocity) are `compileOnly`. Relocations are configured in the Gradle plugin's `CommonSurfPlugin` using an infix DSL:
110
+
All non-platform dependencies are shaded via Shadow and relocated to `dev.slne.surf.api.libs.*` (
111
+
configured in `gradle.properties` as `relocationPrefix`). Platform APIs (Paper, Velocity) are
112
+
`compileOnly`. Relocations are configured in the Gradle plugin's `CommonSurfPlugin` using an infix
Format: `{MC_VERSION}-{LIBRARY_VERSION}` (e.g., `1.21.11-2.62.0`), set in `gradle.properties`. Publishing triggers on pushes to `version/*` branches.
121
+
Format: `{MC_VERSION}-{LIBRARY_VERSION}` (e.g., `1.21.11-2.62.0`), set in `gradle.properties`.
122
+
Publishing triggers on pushes to `version/*` branches.
102
123
103
124
## When Making Changes
104
125
105
-
-**API changes** go in `-api` modules; implementations in `-server` modules. Never expose `-server` types in public API.
106
-
-**New components**: annotate with `@ComponentMeta` (or `@Service`/`@Repository`), implement `Component`, and declare dependencies with `@DependsOnComponent`, `@DependsOnPlugin`, etc.
107
-
-**New bridges**: define interface in `-api` with companion delegation via `requiredService()`, implement in `-server` with `@AutoService`.
108
-
-**New extension functions**: place in a file named `{topic}-extensions.kt` in the appropriate `-api` module.
126
+
-**API changes** go in `-api` modules; implementations in `-server` modules. Never expose `-server`
127
+
types in public API.
128
+
-**New components**: annotate with `@ComponentMeta` (or `@Service`/`@Repository`), implement
129
+
`Component`, and declare dependencies with `@DependsOnComponent`, `@DependsOnPlugin`, etc.
130
+
-**New bridges**: define interface in `-api` with companion delegation via `requiredService()`,
131
+
implement in `-server` with `@AutoService`.
132
+
-**New extension functions**: place in a file named `{topic}-extensions.kt` in the appropriate
133
+
`-api` module.
109
134
-**KDoc**: required for all public API members.
110
135
-**Version catalog**: all dependency versions live in `gradle/libs.versions.toml`.
0 commit comments