Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 29 additions & 0 deletions .github/pull_request_template.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# Pull Request

## Description
<!-- Provide a brief description of the changes in this PR -->

## Type of Change
<!-- Mark the relevant option with an 'x' -->
- [ ] 🐛 Bug fix
- [ ] ✨ New feature
- [ ] 💥 Breaking change
- [ ] ♻️ Refactoring
- [ ] 📚 Documentation
- [ ] 🔧 Chore

## Related Issues
<!-- Link to related issues using "Closes #123", "Fixes #456", "Relates to #789" -->
- Fixes #

## Testing
<!-- Describe the tests you ran to verify your changes -->
- [ ] Unit tests pass
- [ ] Manual testing completed
- [ ] New tests added for new functionality

## Checklist
<!-- Mark completed items with an 'x' -->
- [ ] I have performed a self-review of my own code
- [ ] Tests have been added/updated and pass (if needed)
- [ ] Documentation has been updated (if needed)
38 changes: 38 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
name: CI

on:
push:
branches: [main]
pull_request:
branches: [main]

jobs:
verify:
runs-on: ubuntu-24.04
permissions:
contents: read
packages: read
env:
GITHUB_ACTOR: ${{ github.actor }}
GITHUB_TOKEN: ${{ secrets.GROUNDS_PACKAGES_TOKEN }}
steps:
- uses: actions/checkout@v7
with:
ref: ${{ github.sha }}
fetch-depth: 1
persist-credentials: false
- uses: actions/setup-java@v5
with:
distribution: temurin
java-version: '25'
- name: Verify clean build
run: ./gradlew --no-build-cache clean check

reusable:
needs: verify
permissions:
contents: read
packages: read
secrets:
PACKAGES_TOKEN: ${{ secrets.GROUNDS_PACKAGES_TOKEN }}
uses: groundsgg/.github/.github/workflows/gradle-ci.yml@main
17 changes: 17 additions & 0 deletions .github/workflows/labels.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
name: Label Sync

on:
push:
branches: [main]
paths:
- .github/workflows/labels.yml
pull_request:
paths:
- .github/workflows/labels.yml

jobs:
reusable:
permissions:
contents: read
issues: write
uses: groundsgg/.github/.github/workflows/label-sync.yml@main
15 changes: 15 additions & 0 deletions .github/workflows/release-please.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
name: Release Please

on:
push:
branches: [main]

jobs:
reusable:
permissions:
contents: write
issues: write
pull-requests: write
uses: groundsgg/.github/.github/workflows/release-please.yml@main
secrets:
RELEASE_PLEASE_TOKEN: ${{ secrets.RELEASE_PLEASE_TOKEN }}
18 changes: 18 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
name: Release

on:
push:
tags: [v*]

jobs:
maven:
permissions:
contents: read
packages: write
uses: groundsgg/.github/.github/workflows/gradle-publish.yml@main

docker:
permissions:
contents: read
packages: write
uses: groundsgg/.github/.github/workflows/docker-gradle-build-push.yml@main
6 changes: 5 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,8 @@ hs_err_pid*
replay_pid*

# Kotlin Gradle plugin data, see https://kotlinlang.org/docs/whatsnew20.html#new-directory-for-kotlin-data-in-gradle-projects
.kotlin/
.kotlin/

# Gradle build state
.gradle/
build/
3 changes: 3 additions & 0 deletions .release-please-manifest.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
".": "0.0.0"
}
33 changes: 33 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# syntax=docker/dockerfile:1
#
# The plugin-velocity-jar chart copies this data-only image's final shaded
# Velocity plugin from /jar/plugin.jar. The shared Docker release workflow
# builds linux/amd64 and supplies GitHub Packages credentials as a BuildKit
# secret; no credential is retained in an image layer.

FROM eclipse-temurin:25-jdk AS build
WORKDIR /src

ARG GITHUB_USER

COPY gradle/ gradle/
COPY gradlew settings.gradle.kts build.gradle.kts version.txt ./
COPY velocity/ velocity/

RUN --mount=type=secret,id=github_token,required=true \
/bin/sh -euc '\
: "${GITHUB_USER:?GITHUB_USER build arg is required}"; \
token="$(cat /run/secrets/github_token)"; \
./gradlew --no-daemon :velocity:shadowJar \
-Pgithub.user="${GITHUB_USER}" \
-Pgithub.token="${token}" \
'

RUN mkdir -p /out && \
test "$(find /src/velocity/build/libs -maxdepth 1 -type f -name '*.jar' | wc -l)" -eq 1 && \
cp "$(find /src/velocity/build/libs -maxdepth 1 -type f -name '*.jar' -print -quit)" /out/plugin.jar

FROM alpine:3
RUN mkdir -p /jar
COPY --from=build /out/plugin.jar /jar/plugin.jar
# No ENTRYPOINT or CMD: plugin-velocity-jar copies the JAR from this image.
73 changes: 72 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,73 @@
# plugin-resourcepacks
Velocity PackSet delivery plugin

The Grounds Velocity PackSet delivery plugin. It caches validated PackSet snapshots locally and
delivers an ordered Adventure resource-pack request on player login.

## Requirements

Install [`plugin-config`](https://github.com/groundsgg/plugin-config) alongside this plugin. It
supplies `ConfigDefinition` at runtime and owns the authenticated configuration snapshot,
reconciliation, and change-notification boundary.

Set `GROUNDS_ENVIRONMENT` to the deployment environment name, for example `stage`. The value is
required, must be non-blank, and must not contain whitespace, `/`, or `\\`. It selects this exact
configuration scope:

```text
network/<env>/resourcepacks/global
```

The default document seeds the Stable Grounds PackSet only when no operator document exists:

```json
{
"schemaVersion": 1,
"enabled": true,
"source": {
"baseUrl": "https://cdn.grounds.gg",
"packSet": "grounds-global",
"channel": "stable"
},
"required": true,
"prompt": "Grounds benötigt seine Resourcepacks."
}
```

For Stage, an operator changes only `source.channel` to `edge`; the deployment environment and
PackSet channel are separate choices.

## Runtime boundary

The Velocity runtime reads an immutable in-memory snapshot during player login: login does no
synchronous configuration-service or CDN I/O. The client performs refreshes on its own scheduler
and caches validated CDN state under the plugin data directory at `packset-cache` (normally
`plugins/plugin-resourcepacks/packset-cache`).

An arbitrary HTTPS origin is an administrator capability. Until service-config has application-level
administrator authorization, all configuration writes must remain inside the current
authenticated/private service-config boundary. Do not expose this document for public or
unauthenticated writes.

## Runtime behavior

The plugin sends one ordered Adventure request through `Player.sendResourcePacks`, preserving each
pack's UUID, URI and SHA-1 together with the configured prompt and required flag. It sends only a
source-matched READY snapshot or source-matched DEGRADED fallback, suppresses duplicate
fingerprints per player, resends after a packset or delivery-setting change, and removes that record
on disconnect. A source change reconfigures the same client; it never offers the retained fallback
from the old source. Velocity status events identify a pack UUID but not the request that sent it;
if overlapping targets reuse the same UUID, target attribution is reported as `unknown` even for a
terminal status until the player disconnects or delivery state is cleared, rather than guessing the
newer target.

A genuinely `NOT_READY` configuration does not apply defaults, create a CDN client, or send packs.
After callback installation the plugin probes the latest manager value through the same serialized
delivery path as live changes, closing the registration-to-subscription race. That probe or the
first later valid change starts exactly one client. Shutdown detaches plugin-owned listeners and
closes that client. Local runtime diagnostics expose client status, current and fallback
fingerprints, and requested/accepted/downloaded/failed/declined counters. Untrusted diagnostic text
is replaced by bounded, allowlisted reason codes.

## Current scope

There is no Minestom adapter and no gamemode or per-server PackSet overlay support yet.
92 changes: 92 additions & 0 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
import org.gradle.api.JavaVersion
import org.gradle.api.attributes.java.TargetJvmVersion
import org.gradle.api.tasks.bundling.AbstractArchiveTask
import org.gradle.api.tasks.testing.Test
import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar
import org.jetbrains.kotlin.gradle.dsl.JvmTarget
import org.jetbrains.kotlin.gradle.dsl.KotlinJvmProjectExtension
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
import java.util.zip.ZipFile

plugins {
id("gg.grounds.base-conventions") version "0.8.0" apply false
kotlin("jvm") version "2.2.20" apply false
}

group = "gg.grounds"

val semanticVersion =
Regex(
"(?:0|[1-9]\\d*)\\.(?:0|[1-9]\\d*)\\.(?:0|[1-9]\\d*)(?:-(?:0|[1-9]\\d*|[0-9A-Za-z-]*[A-Za-z-][0-9A-Za-z-]*)(?:\\.(?:0|[1-9]\\d*|[0-9A-Za-z-]*[A-Za-z-][0-9A-Za-z-]*))*)?(?:\\+[0-9A-Za-z-]+(?:\\.[0-9A-Za-z-]+)*)?"
)
val versionFileContents = file("version.txt").readText()
val versionFromFile = versionFileContents.removeSuffix("\n")
check(versionFileContents == versionFromFile || versionFileContents == "$versionFromFile\n") {
"version.txt may contain only one optional trailing newline"
}
check(semanticVersion.matches(versionFromFile)) { "version.txt must contain a strict SemVer version" }
val resolvedVersion = providers.gradleProperty("versionOverride").orNull ?: versionFromFile
check(semanticVersion.matches(resolvedVersion)) { "versionOverride must contain a strict SemVer version" }
version = resolvedVersion

subprojects {
apply(plugin = "gg.grounds.base-conventions")
apply(plugin = "org.jetbrains.kotlin.jvm")
version = rootProject.version

repositories {
mavenCentral()
maven {
url = uri("https://maven.pkg.github.com/groundsgg/*")
credentials {
username = providers.gradleProperty("github.user").orNull ?: System.getenv("GITHUB_ACTOR") ?: ""
password = providers.gradleProperty("github.token").orNull ?: System.getenv("GITHUB_TOKEN") ?: ""
}
}
}

extensions.configure<KotlinJvmProjectExtension> { jvmToolchain(25) }
extensions.configure<org.gradle.api.plugins.JavaPluginExtension> {
sourceCompatibility = JavaVersion.VERSION_24
targetCompatibility = JavaVersion.VERSION_24
}
tasks.withType<KotlinCompile>().configureEach { compilerOptions.jvmTarget.set(JvmTarget.JVM_24) }
configurations.configureEach {
attributes.attribute(TargetJvmVersion.TARGET_JVM_VERSION_ATTRIBUTE, 25)
}
tasks.withType<Test>().configureEach { useJUnitPlatform() }
tasks.withType<AbstractArchiveTask>().configureEach {
isPreserveFileTimestamps = false
isReproducibleFileOrder = true
}
dependencyLocking { lockAllConfigurations() }

afterEvaluate {
if (name == "velocity") {
val shadowJar = tasks.named<ShadowJar>("shadowJar")
val verifyNoOverridePluginMetadata =
tasks.register("verifyNoOverridePluginMetadata") {
dependsOn(shadowJar)
inputs.file(shadowJar.flatMap { it.archiveFile })
doLast {
check(version.toString() == versionFromFile) {
"verifyNoOverridePluginMetadata must run without -PversionOverride"
}
val shadedJar = shadowJar.get().archiveFile.get().asFile
check(shadedJar.isFile) { "shadowJar did not produce ${shadedJar.absolutePath}" }
ZipFile(shadedJar).use { jar ->
val descriptor = jar.getEntry("velocity-plugin.json") ?: error("missing plugin metadata")
val metadata = jar.getInputStream(descriptor).bufferedReader().readText()
check("\"version\":\"$versionFromFile\"" in metadata) {
"plugin metadata version must match version.txt"
}
check("\"id\":\"plugin-config\",\"optional\":false" in metadata) {
"plugin metadata must require plugin-config"
}
}
}
}
tasks.named("check") { dependsOn(verifyNoOverridePluginMetadata) }
}
}
}
Binary file added gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
9 changes: 9 additions & 0 deletions gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-9.5.1-bin.zip
networkTimeout=10000
retries=0
retryBackOffMs=500
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
Loading