Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
0183d4ff27 | ||
|
|
bce513e922 | ||
|
|
8e2d86b2cc | ||
|
|
1d5f5e334e |
No files matched your search
@@ -17,7 +17,7 @@ jobs:
|
||||
uses: actions/setup-java@v4
|
||||
with:
|
||||
distribution: temurin
|
||||
java-version: 17
|
||||
java-version: 25
|
||||
cache: gradle
|
||||
|
||||
- name: Validate conventional commits
|
||||
@@ -35,6 +35,6 @@ jobs:
|
||||
- name: Upload development artifact
|
||||
uses: actions/upload-artifact@v3
|
||||
with:
|
||||
name: spigot-trigger-spawn-${{ github.sha }}
|
||||
name: purpur-trigger-spawn-${{ github.sha }}
|
||||
path: build/libs/*.jar
|
||||
if-no-files-found: error
|
||||
@@ -21,7 +21,7 @@ jobs:
|
||||
uses: actions/setup-java@v4
|
||||
with:
|
||||
distribution: temurin
|
||||
java-version: 17
|
||||
java-version: 25
|
||||
cache: gradle
|
||||
|
||||
- name: Set up Node.js
|
||||
@@ -86,8 +86,8 @@ jobs:
|
||||
if: steps.release.outputs.created == 'true'
|
||||
uses: actions/upload-artifact@v3
|
||||
with:
|
||||
name: spigot-trigger-spawn-${{ steps.release.outputs.version }}
|
||||
path: build/libs/spigot-trigger-spawn-${{ steps.release.outputs.version }}.jar
|
||||
name: purpur-trigger-spawn-${{ steps.release.outputs.version }}
|
||||
path: build/libs/purpur-trigger-spawn-${{ steps.release.outputs.version }}.jar
|
||||
if-no-files-found: error
|
||||
|
||||
- name: Create Gitea release and upload plugin
|
||||
@@ -101,7 +101,7 @@ jobs:
|
||||
PREVIOUS_TAG: ${{ steps.previous_tag.outputs.value }}
|
||||
run: |
|
||||
api_url="${GITEA_SERVER_URL}/api/v1"
|
||||
jar="build/libs/spigot-trigger-spawn-${VERSION}.jar"
|
||||
jar="build/libs/purpur-trigger-spawn-${VERSION}.jar"
|
||||
export RELEASE_BODY
|
||||
if [ -n "$PREVIOUS_TAG" ]; then
|
||||
RELEASE_BODY=$(git log --pretty='format:- %s (%h)' "${PREVIOUS_TAG}..HEAD")
|
||||
@@ -138,4 +138,4 @@ jobs:
|
||||
-H "Authorization: token ${GITEA_TOKEN}" \
|
||||
-H "Content-Type: application/octet-stream" \
|
||||
--data-binary "@${jar}" \
|
||||
"${api_url}/repos/${REPOSITORY}/releases/${release_id}/assets?name=spigot-trigger-spawn-${VERSION}.jar"
|
||||
"${api_url}/repos/${REPOSITORY}/releases/${release_id}/assets?name=purpur-trigger-spawn-${VERSION}.jar"
|
||||
@@ -0,0 +1,9 @@
|
||||
# purpur-trigger-spawn agent entrypoint
|
||||
|
||||
The canonical stories, engineering guidance, and **all process documents** are in the private [SoMC OKF wiki](https://git.garvis.dev/dmg/somc-okf/src/branch/main/index.md).
|
||||
|
||||
Before work, read the sibling `../somc-okf/index.md`, `../somc-okf/processes/index.md`, `../somc-okf/projects/purpur-trigger-spawn/index.md`, `engineering.md` in that project section, and relevant `../somc-okf/user-stories/purpur-trigger-spawn/` stories. Also follow the parent workspace `AGENTS.md` when present.
|
||||
|
||||
For standalone checkouts, start at the [project page](https://git.garvis.dev/dmg/somc-okf/src/branch/main/projects/purpur-trigger-spawn/index.md) and [shared process](https://git.garvis.dev/dmg/somc-okf/src/branch/main/processes/development.md). Obtain wiki access before feature work; do not recreate a local knowledge bundle. Source builds do not require private wiki access.
|
||||
|
||||
Development follows [Development cycle](https://git.garvis.dev/dmg/somc-okf/src/branch/main/runbooks/development-cycle.md): approved stories, failing tests, passing implementation, verification, then source/wiki commit and push. GitOps updates are committed locally **without pushing**; only [Do release](https://git.garvis.dev/dmg/somc-okf/src/branch/main/runbooks/do-release.md) authorizes a reviewed GitOps push.
|
||||
@@ -1,17 +1,22 @@
|
||||
# Trigger Spawn
|
||||
# Purpur Trigger Spawn
|
||||
|
||||
A Spigot 26.2 plugin providing progression-gated, safe teleportation to each world's spawn area.
|
||||
A Purpur 26.3 plugin providing progression-gated, safe teleportation to each world's spawn area.
|
||||
|
||||
Players unlock `/spawn` by killing a Warden, Ender Dragon, or Wither after the plugin is installed. Their first, second, and third unique kills give default cooldowns of 8 hours, 4 hours, and 1 hour respectively. Each new unique kill clears the current cooldown immediately; repeated kills of the same boss do not count.
|
||||
|
||||
`/spawn` uses real elapsed cooldown time, including time offline. An accepted request displays a three-second countdown. Walking to another block, jumping, falling, teleporting, changing worlds, or disconnecting cancels it; looking around does not. The plugin samples a safe destination in the current world's circular spawn area, and failures do not consume the cooldown.
|
||||
|
||||
The behavior under development is specified in the [OKF design bundle](design/index.md).
|
||||
The behavior under development is specified in the [SoMC OKF wiki](https://git.garvis.dev/dmg/somc-okf/src/branch/main/projects/purpur-trigger-spawn/index.md).
|
||||
|
||||
## Requirements
|
||||
|
||||
- Spigot 26.2
|
||||
- Java 17 or newer
|
||||
- Purpur 26.3 build 2651
|
||||
- Java 25
|
||||
|
||||
The automated native lifecycle boundary downloads that exact runtime and accepts it only with
|
||||
SHA-256 `0677c1febecfbc2e5b0a7f76abd647b70a1f38d3cbdf3dd6a82e401b4262a598`.
|
||||
|
||||
Repository, checkout and new artifacts use `purpur-trigger-spawn`. Runtime `TriggerSpawn`, Java entrypoint/packages, `plugins/TriggerSpawn/`, commands/permissions, boss progression, cooldowns and world spawn settings remain unchanged. Replace the old JAR rather than installing both distributions. Old tags/assets remain available; new releases no longer support Java 17.
|
||||
|
||||
## Build
|
||||
|
||||
@@ -19,7 +24,14 @@ The behavior under development is specified in the [OKF design bundle](design/in
|
||||
./gradlew clean check jar
|
||||
```
|
||||
|
||||
The plugin JAR is written to `build/libs/`.
|
||||
The plugin JAR is written to `build/libs/purpur-trigger-spawn-<version>.jar`.
|
||||
`check` includes `nativeLifecycleTest`: it checksum-verifies Purpur 26.3 build 2651, prepares the
|
||||
runtime in Paperclip patch-only mode, and loads, enables, and disables the packaged plugin through
|
||||
Purpur's native JavaPlugin lifecycle. The isolated test verifies command/listener wiring, retained
|
||||
configuration and YAML state without starting a listening server, accepting the EULA, or creating a
|
||||
world. Scheduler, teleport, safe-location, world-border, persistence, metadata, bytecode, and JAR
|
||||
exclusion regressions run alongside that boundary; this is automated compatibility evidence, not a
|
||||
live-server or deployment claim.
|
||||
|
||||
On first startup, the plugin creates `plugins/TriggerSpawn/config.yml`. Its cooldown defaults are:
|
||||
|
||||
|
||||
+72
-5
@@ -1,3 +1,6 @@
|
||||
import java.net.URI
|
||||
import java.security.MessageDigest
|
||||
|
||||
plugins {
|
||||
java
|
||||
}
|
||||
@@ -9,23 +12,23 @@ version = providers.gradleProperty("releaseVersion")
|
||||
|
||||
repositories {
|
||||
mavenCentral()
|
||||
maven("https://hub.spigotmc.org/nexus/content/repositories/snapshots/")
|
||||
maven("https://repo.purpurmc.org/snapshots/")
|
||||
}
|
||||
|
||||
java {
|
||||
toolchain {
|
||||
languageVersion = JavaLanguageVersion.of(17)
|
||||
languageVersion = JavaLanguageVersion.of(25)
|
||||
}
|
||||
}
|
||||
|
||||
tasks.withType<JavaCompile>().configureEach {
|
||||
options.compilerArgs.addAll(listOf("-Xlint:all", "-Werror"))
|
||||
options.compilerArgs.addAll(listOf("-Xlint:all,-deprecation,-removal", "-Werror"))
|
||||
}
|
||||
|
||||
dependencies {
|
||||
compileOnly("org.spigotmc:spigot-api:26.2-R0.1-SNAPSHOT")
|
||||
compileOnly("org.purpurmc.purpur:purpur-api:26.3.build.2651-stable")
|
||||
|
||||
testImplementation("org.spigotmc:spigot-api:26.2-R0.1-SNAPSHOT")
|
||||
testImplementation("org.purpurmc.purpur:purpur-api:26.3.build.2651-stable")
|
||||
testImplementation(platform("org.junit:junit-bom:5.13.4"))
|
||||
testImplementation("org.junit.jupiter:junit-jupiter")
|
||||
testImplementation("org.mockito:mockito-core:5.18.0")
|
||||
@@ -35,8 +38,72 @@ dependencies {
|
||||
|
||||
tasks.test {
|
||||
useJUnitPlatform()
|
||||
dependsOn(tasks.jar)
|
||||
systemProperty("distribution.jar", tasks.jar.get().archiveFile.get().asFile.absolutePath)
|
||||
systemProperty("distribution.version", project.version.toString())
|
||||
}
|
||||
|
||||
val nativeRuntime = layout.buildDirectory.dir("native-runtime")
|
||||
val downloadNativeRuntime = tasks.register("downloadNativeRuntime") {
|
||||
val launcher = nativeRuntime.map { it.file("purpur-26.3-2651.jar") }
|
||||
outputs.file(launcher)
|
||||
outputs.upToDateWhen {
|
||||
val file = launcher.get().asFile
|
||||
file.isFile && MessageDigest.getInstance("SHA-256")
|
||||
.digest(file.readBytes()).joinToString("") { "%02x".format(it) }
|
||||
.equals("0677c1febecfbc2e5b0a7f76abd647b70a1f38d3cbdf3dd6a82e401b4262a598")
|
||||
}
|
||||
doLast {
|
||||
val file = launcher.get().asFile
|
||||
file.parentFile.mkdirs()
|
||||
val connection = URI("https://api.purpurmc.org/v2/purpur/26.3/2651/download")
|
||||
.toURL().openConnection()
|
||||
connection.connectTimeout = 30_000
|
||||
connection.readTimeout = 120_000
|
||||
val bytes = connection.getInputStream().use { it.readBytes() }
|
||||
val digest = MessageDigest.getInstance("SHA-256")
|
||||
.digest(bytes).joinToString("") { "%02x".format(it) }
|
||||
check(digest == "0677c1febecfbc2e5b0a7f76abd647b70a1f38d3cbdf3dd6a82e401b4262a598") {
|
||||
"Purpur 2651 checksum mismatch"
|
||||
}
|
||||
file.writeBytes(bytes)
|
||||
}
|
||||
}
|
||||
val prepareNativeRuntime = tasks.register<JavaExec>("prepareNativeRuntime") {
|
||||
dependsOn(downloadNativeRuntime)
|
||||
javaLauncher = javaToolchains.launcherFor { languageVersion = JavaLanguageVersion.of(25) }
|
||||
classpath = files(nativeRuntime.map { it.file("purpur-26.3-2651.jar") })
|
||||
mainClass = "io.papermc.paperclip.Main"
|
||||
jvmArgs("-Dpaperclip.patchonly=true")
|
||||
workingDir(nativeRuntime)
|
||||
outputs.dir(nativeRuntime.map { it.dir("versions") })
|
||||
outputs.dir(nativeRuntime.map { it.dir("libraries") })
|
||||
}
|
||||
val nativeTest = sourceSets.create("nativeTest")
|
||||
dependencies {
|
||||
add(nativeTest.implementationConfigurationName, platform("org.junit:junit-bom:5.13.4"))
|
||||
add(nativeTest.implementationConfigurationName, "org.junit.jupiter:junit-jupiter")
|
||||
add(nativeTest.compileOnlyConfigurationName, "org.jetbrains:annotations:26.1.0")
|
||||
add(nativeTest.runtimeOnlyConfigurationName, "org.junit.platform:junit-platform-launcher")
|
||||
}
|
||||
val nativeRuntimeJars = files(fileTree(nativeRuntime) {
|
||||
include("versions/**/*.jar", "libraries/**/*.jar")
|
||||
}).builtBy(prepareNativeRuntime)
|
||||
nativeTest.compileClasspath += sourceSets.main.get().output + nativeRuntimeJars
|
||||
nativeTest.runtimeClasspath += sourceSets.main.get().runtimeClasspath + nativeRuntimeJars
|
||||
val nativeLifecycleTest = tasks.register<Test>("nativeLifecycleTest") {
|
||||
description = "Loads, enables, and disables the packaged plugin on the pinned Purpur runtime"
|
||||
dependsOn(tasks.jar)
|
||||
testClassesDirs = nativeTest.output.classesDirs
|
||||
classpath = nativeTest.runtimeClasspath
|
||||
useJUnitPlatform()
|
||||
maxHeapSize = "1G"
|
||||
workingDir(nativeRuntime)
|
||||
systemProperty("distribution.jar", tasks.jar.get().archiveFile.get().asFile.absolutePath)
|
||||
systemProperty("distribution.version", project.version.toString())
|
||||
}
|
||||
tasks.check { dependsOn(nativeLifecycleTest) }
|
||||
|
||||
val pluginVersion = version
|
||||
|
||||
tasks.processResources {
|
||||
|
||||
@@ -1,15 +0,0 @@
|
||||
---
|
||||
type: Index
|
||||
title: Trigger Spawn Design
|
||||
description: Entry point for the Trigger Spawn OKF knowledge bundle.
|
||||
okf_version: "0.1"
|
||||
---
|
||||
|
||||
# Trigger Spawn Design
|
||||
|
||||
This bundle documents the player progression, teleportation, administration, persistence, configuration, and delivery requirements for the Trigger Spawn Spigot plugin.
|
||||
|
||||
## Explore
|
||||
|
||||
- [User stories](user-stories/index.md)
|
||||
- [Design log](log.md)
|
||||
@@ -1,72 +0,0 @@
|
||||
---
|
||||
type: Log
|
||||
title: Trigger Spawn Design Log
|
||||
description: Chronological record of significant Trigger Spawn design decisions.
|
||||
---
|
||||
|
||||
# Trigger Spawn Design Log
|
||||
|
||||
## 2026-08-08 — Initial user stories
|
||||
|
||||
- Target Spigot 26.2 and Java 17 with a Gradle and Gitea Actions pipeline modeled on `spigot-event-producer`.
|
||||
- Unlock `/spawn` after the first observed Warden, Ender Dragon, or Wither kill.
|
||||
- Use real elapsed time for cooldowns, with defaults of eight, four, and one hour as unique boss kills accumulate.
|
||||
- Support administrator-defined cooldown grants, complete access resets, and bans.
|
||||
- Maintain a separate circular spawn area in each world, with a default radius of 20 blocks and safe randomized destinations.
|
||||
- Require a stationary three-second warm-up that is cancelled by walking to another block, jumping, falling, teleportation, or world changes.
|
||||
|
||||
## 2026-08-08 — Progression reminders and rewards
|
||||
|
||||
- Remind players with incomplete progression that remaining unique boss kills permanently reduce the `/spawn` cooldown.
|
||||
- Clear the active cooldown immediately after each newly credited unique boss kill.
|
||||
- When cooldown prevents `/spawn`, explicitly report that it is unavailable and show the remaining wait in a friendly format.
|
||||
|
||||
## 2026-08-08 — Build and release foundation
|
||||
|
||||
- Added the Java 17 Gradle project targeting Spigot API 26.2, with JUnit 5 verification and versioned resource processing.
|
||||
- Added Gitea CI and semantic-release workflows modeled on `spigot-event-producer`.
|
||||
- Documented local builds, public releases, and the required `RELEASE_TOKEN` repository secret.
|
||||
|
||||
## 2026-08-08 — Configuration and persistence
|
||||
|
||||
- Added validated, independently configurable real-time cooldown tiers with documented defaults.
|
||||
- Added atomic YAML persistence for UUID-based player access state and per-world spawn settings.
|
||||
- Invalid persisted access values fail closed, while invalid required configuration disables the plugin rather than allowing partial startup.
|
||||
- Added friendly duration formatting and the administrative permission declaration.
|
||||
|
||||
## 2026-08-08 — Per-world spawn areas
|
||||
|
||||
- Added `/spawnadmin set`, `distance`, and `info` for player-operated configuration of the current world.
|
||||
- Worlds default to their native spawn and an independently persisted 20-block radius.
|
||||
- Circular target sampling is uniform by area, preserves configured facing, and supports a zero-block radius.
|
||||
|
||||
## 2026-08-08 — Administrative access grants
|
||||
|
||||
- Added custom `/spawn` cooldown grants with safe, friendly duration parsing.
|
||||
- Added complete access resets and a paginated view of naturally and administratively eligible players.
|
||||
- Administrative targets resolve online players, persisted names, server-known offline players, and known UUIDs while state remains keyed by UUID.
|
||||
|
||||
## 2026-08-08 — Spawn bans
|
||||
|
||||
- Added persistent `/spawn` bans, unbans, and paginated ban listing for online and resolvable offline players.
|
||||
- Banning immediately clears grants, boss progress, and cooldown state; unbanning restores none of them.
|
||||
- Banned player state cannot retain natural or granted access.
|
||||
|
||||
## 2026-08-08 — Boss progression
|
||||
|
||||
- Added player-attributed Warden, Ender Dragon, and Wither kill observation without importing historical accomplishments.
|
||||
- Unique kills unlock and improve the configured cooldown tier in any order; duplicate kills do not count.
|
||||
- Each credited kill persists UUID-based progress, clears the current cooldown, and displays an on-screen reward plus colored checklist.
|
||||
|
||||
## 2026-08-08 — Safe spawn teleportation
|
||||
|
||||
- Added `/spawn` eligibility and real-time cooldown enforcement with explicit friendly remaining-time messages.
|
||||
- Added a three-second on-screen warm-up cancelled by block movement, jumping, falling, teleportation, world changes, or disconnects.
|
||||
- Safe destinations are sampled within the current world's circle using bounded attempts and a closest-elevation search that rejects environmental hazards.
|
||||
- Only completed teleports consume cooldown, and incomplete progression receives a post-teleport reminder.
|
||||
|
||||
## 2026-08-08 — Progression rewards and reminders
|
||||
|
||||
- Successful `/spawn` teleports now identify each remaining boss and show the next permanent boss-based cooldown tier.
|
||||
- Fully progressed players receive no unnecessary reminder.
|
||||
- Verified that newly credited unique kills make `/spawn` immediately available while duplicate kills preserve the existing cooldown.
|
||||
@@ -1,16 +0,0 @@
|
||||
---
|
||||
type: Index
|
||||
title: Trigger Spawn User Stories
|
||||
description: Catalog of user stories for the Trigger Spawn Spigot plugin.
|
||||
---
|
||||
|
||||
# Trigger Spawn User Stories
|
||||
|
||||
1. [US-001: Earn progressive spawn access](us-001-earn-progressive-spawn-access.md)
|
||||
2. [US-002: Teleport safely to spawn](us-002-teleport-safely-to-spawn.md)
|
||||
3. [US-003: Configure each world's spawn area](us-003-configure-world-spawn-area.md)
|
||||
4. [US-004: Grant and remove spawn access](us-004-manage-spawn-access.md)
|
||||
5. [US-005: Ban and unban spawn access](us-005-manage-spawn-bans.md)
|
||||
6. [US-006: Configure plugin behavior](us-006-configure-plugin-behavior.md)
|
||||
7. [US-007: Build and release the plugin](us-007-build-and-release-plugin.md)
|
||||
8. [US-008: Reward and encourage spawn progression](us-008-reward-spawn-progression.md)
|
||||
@@ -1,31 +0,0 @@
|
||||
---
|
||||
type: User Story
|
||||
title: "US-001: Earn progressive spawn access"
|
||||
description: Let players unlock spawn teleportation and improve its cooldown by defeating dangerous enemies.
|
||||
status: done
|
||||
---
|
||||
|
||||
# US-001: Earn progressive spawn access
|
||||
|
||||
As a **player**, I want to unlock `/spawn` by defeating major enemies so that my progression earns increasingly convenient access to spawn.
|
||||
|
||||
## Acceptance criteria
|
||||
|
||||
- [x] The plugin observes player-attributed kills of the Warden, Ender Dragon, and Wither.
|
||||
- [x] Only kills observed while the plugin is operating count; historical statistics and advancements are not imported.
|
||||
- [x] The three enemies may be killed in any order.
|
||||
- [x] The first unique qualifying kill unlocks `/spawn` with the configured one-kill cooldown, which defaults to 8 hours.
|
||||
- [x] The second unique qualifying kill applies the configured two-kill cooldown, which defaults to 4 hours.
|
||||
- [x] The third unique qualifying kill applies the configured three-kill cooldown, which defaults to 1 hour.
|
||||
- [x] Repeated kills of an already credited enemy do not improve the player's tier.
|
||||
- [x] Each newly credited kill displays an on-screen message stating that `/spawn` has been unlocked or updated, is immediately available, and has the shown applicable cooldown.
|
||||
- [x] Progress is presented as a checklist in which credited enemies have a green check and uncredited enemies have a red cross.
|
||||
- [x] Each newly credited unique kill immediately clears any active `/spawn` cooldown as a progression reward.
|
||||
- [x] Progress is associated with the player's UUID and survives server and plugin restarts.
|
||||
|
||||
## Related
|
||||
|
||||
- [US-002: Teleport safely to spawn](us-002-teleport-safely-to-spawn.md)
|
||||
- [US-004: Grant and remove spawn access](us-004-manage-spawn-access.md)
|
||||
- [US-005: Ban and unban spawn access](us-005-manage-spawn-bans.md)
|
||||
- [US-008: Reward and encourage spawn progression](us-008-reward-spawn-progression.md)
|
||||
@@ -1,37 +0,0 @@
|
||||
---
|
||||
type: User Story
|
||||
title: "US-002: Teleport safely to spawn"
|
||||
description: Let eligible players teleport to a safe randomized location in their current world's spawn area after a stationary warm-up.
|
||||
status: done
|
||||
---
|
||||
|
||||
# US-002: Teleport safely to spawn
|
||||
|
||||
As an **eligible player**, I want `/spawn` to take me safely to my current world's spawn area so that I can return without exposing myself to an unsafe destination.
|
||||
|
||||
## Acceptance criteria
|
||||
|
||||
- [x] `/spawn` is available after at least one qualifying unique enemy kill or an administrative grant.
|
||||
- [x] A player without access receives a message instructing them to defeat a Warden, Ender Dragon, or Wither and sees the colored progress checklist.
|
||||
- [x] A banned player cannot begin a spawn teleport.
|
||||
- [x] When an active cooldown prevents `/spawn`, the player is explicitly told that the command is unavailable and sees the remaining wait in a friendly duration format.
|
||||
- [x] Cooldowns use real elapsed time and therefore continue while the player is offline.
|
||||
- [x] An accepted teleport request starts a three-second on-screen countdown.
|
||||
- [x] The player may look around during the countdown without cancelling it.
|
||||
- [x] A change to the player's block X, Y, or Z coordinate cancels the countdown, including walking to another block, jumping, or falling.
|
||||
- [x] Teleportation or a world change during the countdown cancels it.
|
||||
- [x] The destination is sampled randomly within the circular spawn area configured for the player's current world.
|
||||
- [x] The destination provides non-hazardous solid ground, two blocks of clear headroom, and no immediate lava, fire, water, void, or other configured environmental hazard.
|
||||
- [x] Unsafe underwater, leaf-top, inaccessible Nether-roof, and void-exposed destinations are rejected.
|
||||
- [x] The safe search prefers a valid vertical position closest to the configured spawn center's elevation rather than automatically preferring the world's highest surface.
|
||||
- [x] The safe-location search uses a bounded number of attempts and reports failure clearly when no destination is found.
|
||||
- [x] Only a completed teleport starts the applicable cooldown.
|
||||
- [x] After a completed teleport, a player with unfinished boss progression is reminded that defeating each remaining unique boss permanently reduces the cooldown.
|
||||
- [x] A cancelled countdown or failed safe-location search does not consume the cooldown.
|
||||
|
||||
## Related
|
||||
|
||||
- [US-001: Earn progressive spawn access](us-001-earn-progressive-spawn-access.md)
|
||||
- [US-003: Configure each world's spawn area](us-003-configure-world-spawn-area.md)
|
||||
- [US-006: Configure plugin behavior](us-006-configure-plugin-behavior.md)
|
||||
- [US-008: Reward and encourage spawn progression](us-008-reward-spawn-progression.md)
|
||||
@@ -1,29 +0,0 @@
|
||||
---
|
||||
type: User Story
|
||||
title: "US-003: Configure each world's spawn area"
|
||||
description: Let administrators define an independent center and circular safe-spawn radius for every world.
|
||||
status: done
|
||||
---
|
||||
|
||||
# US-003: Configure each world's spawn area
|
||||
|
||||
As a **server administrator**, I want to configure the spawn area independently in each world so that `/spawn` sends players to an appropriate safe area in their current world.
|
||||
|
||||
## Acceptance criteria
|
||||
|
||||
- [x] Every world has an independent spawn center and maximum spawn distance.
|
||||
- [x] Until an administrator sets a custom center, a world uses its native world spawn point.
|
||||
- [x] `/spawnadmin set` stores the executing administrator's current world, coordinates, yaw, and pitch as that world's center and facing direction.
|
||||
- [x] `/spawnadmin distance <blocks>` sets the current world's maximum spawn distance in blocks.
|
||||
- [x] `/spawnadmin info` displays the current world's effective center, whether it is native or custom, and maximum distance.
|
||||
- [x] The default maximum spawn distance is 20 blocks.
|
||||
- [x] The spawn area is circular, and random horizontal points are sampled uniformly by area within its radius.
|
||||
- [x] A maximum distance of `0` targets the configured center and adjusts it to the nearest safe block.
|
||||
- [x] Negative, non-numeric, or otherwise invalid distances are rejected with an explanatory message.
|
||||
- [x] Random destinations use the center's saved yaw and pitch.
|
||||
- [x] Per-world centers and distances survive server and plugin restarts.
|
||||
|
||||
## Related
|
||||
|
||||
- [US-002: Teleport safely to spawn](us-002-teleport-safely-to-spawn.md)
|
||||
- [US-006: Configure plugin behavior](us-006-configure-plugin-behavior.md)
|
||||
@@ -1,30 +0,0 @@
|
||||
---
|
||||
type: User Story
|
||||
title: "US-004: Grant and remove spawn access"
|
||||
description: Let administrators grant custom spawn cooldowns, inspect access, and completely reset a player's access.
|
||||
status: done
|
||||
---
|
||||
|
||||
# US-004: Grant and remove spawn access
|
||||
|
||||
As a **server administrator**, I want to grant, inspect, and remove spawn access so that I can manage exceptions independently of boss progression.
|
||||
|
||||
## Acceptance criteria
|
||||
|
||||
- [x] `/spawnadmin grant <player> <duration>` grants immediate `/spawn` access with the supplied cooldown.
|
||||
- [x] Friendly, case-insensitive duration units are accepted, including values such as `30m`, `2h`, and `1d`.
|
||||
- [x] Zero, negative, malformed, or overflowing grant durations are rejected with an explanatory message.
|
||||
- [x] A custom administrative grant overrides the player's boss-based cooldown tier while the grant exists.
|
||||
- [x] Killing qualifying enemies does not replace an active administrative grant's custom cooldown.
|
||||
- [x] `/spawnadmin remove <player>` removes any administrative grant, recorded enemy progress, and active cooldown from the player.
|
||||
- [x] After removal, the player begins with no access and can earn it again by defeating a qualifying enemy.
|
||||
- [x] `/spawnadmin access [page]` lists all players who currently have natural or granted access, including offline players.
|
||||
- [x] Each access-list entry identifies the player, access source, applicable cooldown, progression tier when relevant, and current remaining cooldown.
|
||||
- [x] Administrative player arguments support online players and previously known offline players when they can be resolved safely.
|
||||
- [x] Player state is stored by UUID while retaining the latest known player name for display and lookup.
|
||||
|
||||
## Related
|
||||
|
||||
- [US-001: Earn progressive spawn access](us-001-earn-progressive-spawn-access.md)
|
||||
- [US-005: Ban and unban spawn access](us-005-manage-spawn-bans.md)
|
||||
- [US-006: Configure plugin behavior](us-006-configure-plugin-behavior.md)
|
||||
@@ -1,27 +0,0 @@
|
||||
---
|
||||
type: User Story
|
||||
title: "US-005: Ban and unban spawn access"
|
||||
description: Let administrators prevent selected players from using or reacquiring spawn teleportation until unbanned.
|
||||
status: done
|
||||
---
|
||||
|
||||
# US-005: Ban and unban spawn access
|
||||
|
||||
As a **server administrator**, I want to ban and unban players from spawn teleportation so that access can be withheld regardless of progression or grants.
|
||||
|
||||
## Acceptance criteria
|
||||
|
||||
- [x] `/spawnadmin ban <player>` immediately prevents the player from using `/spawn`.
|
||||
- [x] Banning a player clears their administrative grant, enemy progress, and active cooldown.
|
||||
- [x] Qualifying kills made while banned are not recorded.
|
||||
- [x] A banned player cannot receive an administrative grant until unbanned.
|
||||
- [x] `/spawnadmin bans [page]` displays a paginated list of banned players, including offline players.
|
||||
- [x] `/spawnadmin unban <player>` removes the ban without restoring any prior grant, enemy progress, or cooldown.
|
||||
- [x] An unbanned player begins with no access and can earn access again by defeating a qualifying enemy or receiving a new grant.
|
||||
- [x] Ban and unban commands support online players and previously known offline players when they can be resolved safely.
|
||||
- [x] Ban state is associated with player UUIDs and survives server and plugin restarts.
|
||||
|
||||
## Related
|
||||
|
||||
- [US-001: Earn progressive spawn access](us-001-earn-progressive-spawn-access.md)
|
||||
- [US-004: Grant and remove spawn access](us-004-manage-spawn-access.md)
|
||||
@@ -1,31 +0,0 @@
|
||||
---
|
||||
type: User Story
|
||||
title: "US-006: Configure plugin behavior"
|
||||
description: Let operators tune cooldown tiers and run the plugin with clear validation, messages, permissions, and durable state.
|
||||
status: done
|
||||
---
|
||||
|
||||
# US-006: Configure plugin behavior
|
||||
|
||||
As a **server operator**, I want safe configuration and durable state so that Trigger Spawn behaves predictably across worlds and restarts.
|
||||
|
||||
## Acceptance criteria
|
||||
|
||||
- [x] The one-kill cooldown is independently configurable and defaults to 28,800 seconds.
|
||||
- [x] The two-kill cooldown is independently configurable and defaults to 14,400 seconds.
|
||||
- [x] The three-kill cooldown is independently configurable and defaults to 3,600 seconds.
|
||||
- [x] Configured cooldowns must be positive and representable safely by the plugin.
|
||||
- [x] Invalid required configuration prevents partial initialization and produces a clear server log message.
|
||||
- [x] Player-facing messages use clear built-in wording, readable colors, and friendly duration formatting.
|
||||
- [x] Ordinary players do not require a plugin permission node to execute `/spawn`; eligibility is controlled by progression, grants, cooldowns, and bans.
|
||||
- [x] Administrative commands require `triggerspawn.admin`.
|
||||
- [x] Server operators receive `triggerspawn.admin` by default.
|
||||
- [x] Boss progress, grants, bans, cooldown timestamps, latest known names, and per-world spawn settings persist across clean restarts.
|
||||
- [x] Persisted data is handled defensively so corrupt or invalid records do not silently grant access.
|
||||
|
||||
## Related
|
||||
|
||||
- [US-001: Earn progressive spawn access](us-001-earn-progressive-spawn-access.md)
|
||||
- [US-003: Configure each world's spawn area](us-003-configure-world-spawn-area.md)
|
||||
- [US-004: Grant and remove spawn access](us-004-manage-spawn-access.md)
|
||||
- [US-005: Ban and unban spawn access](us-005-manage-spawn-bans.md)
|
||||
@@ -1,25 +0,0 @@
|
||||
---
|
||||
type: User Story
|
||||
title: "US-007: Build and release the plugin"
|
||||
description: Give maintainers repeatable Spigot 26.2 builds, automated verification, and versioned Gitea releases.
|
||||
status: done
|
||||
---
|
||||
|
||||
# US-007: Build and release the plugin
|
||||
|
||||
As a **plugin maintainer**, I want automated builds and releases so that tested, correctly versioned plugin artifacts can be distributed consistently.
|
||||
|
||||
## Acceptance criteria
|
||||
|
||||
- [x] The Gradle project compiles against Spigot API `26.2-R0.1-SNAPSHOT` using a Java 17 toolchain.
|
||||
- [x] Automated JUnit 5 tests run as part of the Gradle check lifecycle.
|
||||
- [x] Pushes and pull requests build and test the plugin in Gitea Actions.
|
||||
- [x] Pull requests validate conventional commit messages.
|
||||
- [x] CI stores a development JAR as a workflow artifact.
|
||||
- [x] Main-branch conventional commits drive semantic versioning.
|
||||
- [x] A successful release builds a versioned JAR and attaches it to the corresponding Gitea release.
|
||||
- [x] The build and release workflow follows the established `spigot-event-producer` project pattern where applicable.
|
||||
|
||||
## Related
|
||||
|
||||
- [User-story catalog](index.md)
|
||||
@@ -1,28 +0,0 @@
|
||||
---
|
||||
type: User Story
|
||||
title: "US-008: Reward and encourage spawn progression"
|
||||
description: Remind players how to improve spawn access and reward each newly credited unique boss kill with an immediate cooldown reset.
|
||||
status: done
|
||||
---
|
||||
|
||||
# US-008: Reward and encourage spawn progression
|
||||
|
||||
As a **player**, I want `/spawn` to explain how I can improve its cooldown and reward new boss progress so that the benefit of defeating each remaining boss is clear and immediately useful.
|
||||
|
||||
## Acceptance criteria
|
||||
|
||||
- [x] After every successful `/spawn`, a player who has not defeated all three unique qualifying enemies receives a reminder that defeating the remaining bosses permanently reduces the cooldown.
|
||||
- [x] The reminder identifies the remaining eligible bosses and shows the next cooldown tier.
|
||||
- [x] A player who has completed all three unique qualifying kills does not receive the progression reminder.
|
||||
- [x] Each newly credited unique Warden, Ender Dragon, or Wither kill immediately clears the player's active `/spawn` cooldown.
|
||||
- [x] Clearing the cooldown makes `/spawn` immediately available as a progression reward.
|
||||
- [x] The newly credited kill also permanently applies the improved boss-based cooldown tier.
|
||||
- [x] Repeated kills of an already credited enemy do not clear the cooldown.
|
||||
- [x] The on-screen kill message states that `/spawn` is immediately available and displays the new cooldown tier.
|
||||
- [x] Banned players cannot earn kill credit, a cooldown reset, or an improved tier.
|
||||
|
||||
## Related
|
||||
|
||||
- [US-001: Earn progressive spawn access](us-001-earn-progressive-spawn-access.md)
|
||||
- [US-002: Teleport safely to spawn](us-002-teleport-safely-to-spawn.md)
|
||||
- [US-005: Ban and unban spawn access](us-005-manage-spawn-bans.md)
|
||||
+1
-1
@@ -1 +1 @@
|
||||
rootProject.name = "spigot-trigger-spawn"
|
||||
rootProject.name = "purpur-trigger-spawn"
|
||||
@@ -1,8 +1,10 @@
|
||||
package games.dmg.triggerspawn;
|
||||
|
||||
import java.util.EnumSet;
|
||||
import java.util.Objects;
|
||||
import java.util.Optional;
|
||||
import java.util.Set;
|
||||
import java.util.function.Predicate;
|
||||
import java.util.random.RandomGenerator;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
@@ -28,6 +30,17 @@ final class SafeSpawnFinder {
|
||||
Material.FIRE,
|
||||
Material.SOUL_FIRE,
|
||||
Material.POWDER_SNOW);
|
||||
private final Predicate<Material> solidMaterial;
|
||||
private final Predicate<Material> leafMaterial;
|
||||
|
||||
SafeSpawnFinder() {
|
||||
this(Material::isSolid, material -> Tag.LEAVES.isTagged(material));
|
||||
}
|
||||
|
||||
SafeSpawnFinder(Predicate<Material> solidMaterial, Predicate<Material> leafMaterial) {
|
||||
this.solidMaterial = Objects.requireNonNull(solidMaterial);
|
||||
this.leafMaterial = Objects.requireNonNull(leafMaterial);
|
||||
}
|
||||
|
||||
Optional<Location> find(
|
||||
World world,
|
||||
@@ -64,13 +77,13 @@ final class SafeSpawnFinder {
|
||||
return Optional.empty();
|
||||
}
|
||||
|
||||
private static boolean isSafe(World world, int x, int feetY, int z) {
|
||||
private boolean isSafe(World world, int x, int feetY, int z) {
|
||||
Block ground = world.getBlockAt(x, feetY - 1, z);
|
||||
Block feet = world.getBlockAt(x, feetY, z);
|
||||
Block head = world.getBlockAt(x, feetY + 1, z);
|
||||
Material groundType = ground.getType();
|
||||
return groundType.isSolid()
|
||||
&& !Tag.LEAVES.isTagged(groundType)
|
||||
return solidMaterial.test(groundType)
|
||||
&& !leafMaterial.test(groundType)
|
||||
&& !UNSAFE_GROUND.contains(groundType)
|
||||
&& isClear(feet)
|
||||
&& isClear(head);
|
||||
|
||||
@@ -6,7 +6,7 @@ import java.util.logging.Level;
|
||||
import org.bukkit.command.PluginCommand;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
/** Entry point for the Trigger Spawn Spigot plugin. */
|
||||
/** Entry point for the Trigger Spawn Purpur plugin. */
|
||||
public final class TriggerSpawnPlugin extends JavaPlugin {
|
||||
private PluginSettings settings;
|
||||
private SpawnStateManager stateManager;
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
name: TriggerSpawn
|
||||
version: '${version}'
|
||||
main: games.dmg.triggerspawn.TriggerSpawnPlugin
|
||||
api-version: '26.2'
|
||||
api-version: '26.3'
|
||||
author: dmg.games
|
||||
description: Provides progression-gated safe teleportation to each world's spawn area.
|
||||
commands:
|
||||
|
||||
@@ -0,0 +1,202 @@
|
||||
package games.dmg.triggerspawn;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
|
||||
import io.papermc.paper.plugin.configuration.PluginMeta;
|
||||
import io.papermc.paper.plugin.provider.classloader.ConfiguredPluginClassLoader;
|
||||
import io.papermc.paper.plugin.provider.classloader.PluginClassLoaderGroup;
|
||||
import java.lang.reflect.Proxy;
|
||||
import java.net.URL;
|
||||
import java.net.URLClassLoader;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.jar.JarFile;
|
||||
import java.util.logging.Logger;
|
||||
import org.bukkit.Server;
|
||||
import org.bukkit.command.PluginCommand;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.plugin.PluginDescriptionFile;
|
||||
import org.bukkit.plugin.PluginManager;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.io.TempDir;
|
||||
|
||||
/** Exercises the packaged entrypoint through Purpur's native JavaPlugin lifecycle. */
|
||||
class TriggerSpawnLifecycleNativeTest {
|
||||
private static final String PLAYER_ID = "00000000-0000-0000-0000-000000000417";
|
||||
private static final String WORLD_ID = "00000000-0000-0000-0000-000000002651";
|
||||
|
||||
@TempDir Path temporaryDirectory;
|
||||
|
||||
@Test
|
||||
void packagedPluginLoadsEnablesRetainsYamlStateAndDisables() throws Exception {
|
||||
Path dataDirectory = temporaryDirectory.resolve("TriggerSpawn");
|
||||
Files.createDirectories(dataDirectory);
|
||||
Path stateFile = dataDirectory.resolve("state.yml");
|
||||
Files.writeString(stateFile, """
|
||||
players:
|
||||
%s:
|
||||
name: Alex
|
||||
defeated: [WARDEN]
|
||||
banned: false
|
||||
grant-cooldown-seconds: 1800
|
||||
last-spawn-epoch-millis: 1750000000000
|
||||
worlds:
|
||||
%s:
|
||||
name: overworld
|
||||
max-distance: 12
|
||||
center:
|
||||
x: 12.5
|
||||
y: 70.0
|
||||
z: -8.5
|
||||
yaw: 90.0
|
||||
pitch: 10.0
|
||||
""".formatted(PLAYER_ID, WORLD_ID));
|
||||
Path unrelatedState = temporaryDirectory.resolve("OtherPlugin/owned.txt");
|
||||
Files.createDirectories(unrelatedState.getParent());
|
||||
Files.writeString(unrelatedState, "keep");
|
||||
|
||||
List<Class<?>> listenerTypes = new ArrayList<>();
|
||||
Map<String, PluginCommand> commands = new HashMap<>();
|
||||
PluginManager manager = port(PluginManager.class, (name, arguments) -> switch (name) {
|
||||
case "registerEvents" -> {
|
||||
listenerTypes.add(((Listener) arguments[0]).getClass());
|
||||
yield null;
|
||||
}
|
||||
case "disablePlugin" -> throw new AssertionError("Native lifecycle initialization failed");
|
||||
default -> throw new AssertionError("Unexpected plugin-manager call " + name);
|
||||
});
|
||||
Server server = port(Server.class, (name, arguments) -> switch (name) {
|
||||
case "getPluginManager" -> manager;
|
||||
case "getPluginCommand" -> commands.get(arguments[0]);
|
||||
case "getLogger" -> Logger.getLogger("TriggerSpawn lifecycle fixture");
|
||||
case "getWarningState" -> org.bukkit.Warning.WarningState.DEFAULT;
|
||||
case "getName" -> "Purpur";
|
||||
case "getVersion" -> "Purpur 2651 (MC: 26.3)";
|
||||
case "getMinecraftVersion" -> "26.3";
|
||||
case "isPrimaryThread" -> true;
|
||||
default -> throw new AssertionError("Unexpected server call " + name);
|
||||
});
|
||||
|
||||
try (var loader = new Loader(server, dataDirectory)) {
|
||||
JavaPlugin plugin = (JavaPlugin) loader.loadClass(
|
||||
"games.dmg.triggerspawn.TriggerSpawnPlugin").getConstructor().newInstance();
|
||||
var commandConstructor = PluginCommand.class.getDeclaredConstructor(
|
||||
String.class, org.bukkit.plugin.Plugin.class);
|
||||
commandConstructor.setAccessible(true);
|
||||
commands.put("spawn", commandConstructor.newInstance("spawn", plugin));
|
||||
commands.put("spawnadmin", commandConstructor.newInstance("spawnadmin", plugin));
|
||||
|
||||
assertEquals("TriggerSpawn", plugin.getName());
|
||||
assertEquals("26.3", loader.getConfiguration().getAPIVersion());
|
||||
assertEquals("TriggerSpawn", dataDirectory.getFileName().toString());
|
||||
assertFalse(plugin.isEnabled());
|
||||
|
||||
plugin.setEnabled(true);
|
||||
try {
|
||||
assertTrue(plugin.isEnabled());
|
||||
assertEquals(Set.of("SpawnCommand", "BossKillListener"), listenerTypes.stream()
|
||||
.map(Class::getSimpleName).collect(java.util.stream.Collectors.toSet()));
|
||||
assertEquals("SpawnCommand", commands.get("spawn").getExecutor().getClass().getSimpleName());
|
||||
assertEquals("SpawnAdminCommand", commands.get("spawnadmin").getExecutor().getClass().getSimpleName());
|
||||
assertEquals("SpawnAdminCommand", commands.get("spawnadmin").getTabCompleter().getClass().getSimpleName());
|
||||
assertTrue(Files.isRegularFile(dataDirectory.resolve("config.yml")));
|
||||
Files.delete(stateFile);
|
||||
assertFalse(Files.exists(stateFile), "Disable must recreate state loaded during enable");
|
||||
} finally {
|
||||
plugin.setEnabled(false);
|
||||
}
|
||||
assertFalse(plugin.isEnabled());
|
||||
}
|
||||
|
||||
YamlConfiguration saved = YamlConfiguration.loadConfiguration(stateFile.toFile());
|
||||
assertEquals("Alex", saved.getString("players." + PLAYER_ID + ".name"));
|
||||
assertEquals(List.of("WARDEN"), saved.getStringList("players." + PLAYER_ID + ".defeated"));
|
||||
assertEquals(1800L, saved.getLong("players." + PLAYER_ID + ".grant-cooldown-seconds"));
|
||||
assertEquals("overworld", saved.getString("worlds." + WORLD_ID + ".name"));
|
||||
assertEquals(12, saved.getInt("worlds." + WORLD_ID + ".max-distance"));
|
||||
assertEquals(12.5, saved.getDouble("worlds." + WORLD_ID + ".center.x"));
|
||||
assertEquals("keep", Files.readString(unrelatedState));
|
||||
}
|
||||
|
||||
static final class Loader extends URLClassLoader implements ConfiguredPluginClassLoader {
|
||||
private static final String PACKAGE = "games.dmg.triggerspawn.";
|
||||
private final Server server;
|
||||
private final Path dataDirectory;
|
||||
private final Path jar = Path.of(System.getProperty("distribution.jar"));
|
||||
private final PluginDescriptionFile description;
|
||||
private JavaPlugin plugin;
|
||||
|
||||
Loader(Server server, Path dataDirectory) throws Exception {
|
||||
super(new URL[] {Path.of(System.getProperty("distribution.jar")).toUri().toURL()},
|
||||
TriggerSpawnLifecycleNativeTest.class.getClassLoader());
|
||||
this.server = server;
|
||||
this.dataDirectory = dataDirectory;
|
||||
try (var archive = new JarFile(jar.toFile());
|
||||
var input = archive.getInputStream(archive.getJarEntry("plugin.yml"))) {
|
||||
description = new PluginDescriptionFile(input);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Class<?> loadClass(String name, boolean resolve) throws ClassNotFoundException {
|
||||
synchronized (getClassLoadingLock(name)) {
|
||||
if (!name.startsWith(PACKAGE) || name.equals(getClass().getName())) {
|
||||
return super.loadClass(name, resolve);
|
||||
}
|
||||
Class<?> loaded = findLoadedClass(name);
|
||||
if (loaded == null) {
|
||||
loaded = findClass(name);
|
||||
}
|
||||
if (resolve) {
|
||||
resolveClass(loaded);
|
||||
}
|
||||
return loaded;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class<?> loadClass(String name, boolean resolve, boolean global, boolean libraries)
|
||||
throws ClassNotFoundException {
|
||||
return loadClass(name, resolve);
|
||||
}
|
||||
|
||||
@Override public PluginMeta getConfiguration() { return description; }
|
||||
@Override public JavaPlugin getPlugin() { return plugin; }
|
||||
@Override public PluginClassLoaderGroup getGroup() { return null; }
|
||||
|
||||
@Override
|
||||
public void init(JavaPlugin created) {
|
||||
plugin = created;
|
||||
created.init(server, description, dataDirectory.toFile(), jar.toFile(), this, description,
|
||||
Logger.getLogger("TriggerSpawn lifecycle fixture"));
|
||||
}
|
||||
}
|
||||
|
||||
@FunctionalInterface
|
||||
interface Call {
|
||||
Object invoke(String name, Object[] arguments);
|
||||
}
|
||||
|
||||
static <T> T port(Class<T> type, Call call) {
|
||||
return type.cast(Proxy.newProxyInstance(type.getClassLoader(), new Class<?>[] {type},
|
||||
(object, method, arguments) -> {
|
||||
Object[] values = arguments == null ? new Object[0] : arguments;
|
||||
if (method.getDeclaringClass() == Object.class) {
|
||||
return switch (method.getName()) {
|
||||
case "equals" -> object == values[0];
|
||||
case "hashCode" -> System.identityHashCode(object);
|
||||
case "toString" -> "Lifecycle port " + type.getSimpleName();
|
||||
default -> throw new AssertionError(method.getName());
|
||||
};
|
||||
}
|
||||
return call.invoke(method.getName(), values);
|
||||
}));
|
||||
}
|
||||
}
|
||||
@@ -18,7 +18,7 @@ final class PluginMetadataTest {
|
||||
}
|
||||
|
||||
assertEquals("TriggerSpawn", metadata.get("name"));
|
||||
assertEquals("26.2", metadata.get("api-version"));
|
||||
assertEquals("26.3", metadata.get("api-version"));
|
||||
assertEquals("games.dmg.triggerspawn.TriggerSpawnPlugin", metadata.get("main"));
|
||||
assertNotNull(Class.forName((String) metadata.get("main")));
|
||||
}
|
||||
|
||||
@@ -0,0 +1,83 @@
|
||||
package games.dmg.triggerspawn;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
|
||||
import java.io.DataInputStream;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.jar.JarFile;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.yaml.snakeyaml.Yaml;
|
||||
|
||||
class PurpurDistributionTest {
|
||||
@Test
|
||||
void packagesNewNameWithoutChangingRuntimeIdentityOrBundlingTheApi() throws Exception {
|
||||
Path artifact = Path.of(System.getProperty("distribution.jar"));
|
||||
String version = System.getProperty("distribution.version");
|
||||
assertEquals("purpur-trigger-spawn-" + version + ".jar", artifact.getFileName().toString());
|
||||
try (var jar = new JarFile(artifact.toFile())) {
|
||||
Map<?, ?> metadata = new Yaml().load(jar.getInputStream(jar.getJarEntry("plugin.yml")));
|
||||
assertEquals(version, metadata.get("version"));
|
||||
assertEquals("TriggerSpawn", metadata.get("name"), "Retain the data directory and persistent namespace");
|
||||
assertEquals("games.dmg.triggerspawn.TriggerSpawnPlugin", metadata.get("main"));
|
||||
assertEquals("26.3", metadata.get("api-version"));
|
||||
Map<?, ?> commands = (Map<?, ?>) metadata.get("commands");
|
||||
assertEquals(Set.of("spawn", "spawnadmin"), commands.keySet());
|
||||
assertEquals("/spawn", ((Map<?, ?>) commands.get("spawn")).get("usage"));
|
||||
assertEquals(
|
||||
"/spawnadmin <set|distance|info|grant|remove|access|ban|unban|bans>",
|
||||
((Map<?, ?>) commands.get("spawnadmin")).get("usage"));
|
||||
assertEquals("triggerspawn.admin", ((Map<?, ?>) commands.get("spawnadmin")).get("permission"));
|
||||
Map<?, ?> permissions = (Map<?, ?>) metadata.get("permissions");
|
||||
assertEquals(Set.of("triggerspawn.admin"), permissions.keySet());
|
||||
assertEquals("op", ((Map<?, ?>) permissions.get("triggerspawn.admin")).get("default"));
|
||||
assertNull(metadata.get("depend"));
|
||||
assertNull(metadata.get("softdepend"));
|
||||
assertFalse(jar.stream().anyMatch(entry -> entry.getName().startsWith("org/bukkit/")
|
||||
|| entry.getName().startsWith("org/purpurmc/")
|
||||
|| entry.getName().startsWith("io/papermc/")
|
||||
|| entry.getName().startsWith("net/minecraft/")
|
||||
|| entry.getName().startsWith("com/destroystokyo/")
|
||||
|| entry.getName().startsWith("com/comphenix/protocol/")
|
||||
|| entry.getName().startsWith("org/junit/")
|
||||
|| entry.getName().startsWith("org/mockito/")
|
||||
|| entry.getName().endsWith("Test.class")));
|
||||
assertNull(jar.getJarEntry("junit-platform.properties"));
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
void pluginBytecodeTargetsJava25() throws Exception {
|
||||
try (var jar = new JarFile(System.getProperty("distribution.jar"));
|
||||
var bytecode = new DataInputStream(jar.getInputStream(
|
||||
jar.getJarEntry("games/dmg/triggerspawn/TriggerSpawnPlugin.class")))) {
|
||||
assertEquals(0xCAFEBABE, bytecode.readInt());
|
||||
bytecode.readUnsignedShort();
|
||||
assertEquals(69, bytecode.readUnsignedShort());
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
void releaseAndCiAgreeWithThePurpurDistributionNameAndToolchain() throws Exception {
|
||||
String build = Files.readString(Path.of("build.gradle.kts"));
|
||||
assertTrue(build.contains("purpur-api:26.3.build.2651-stable"));
|
||||
assertTrue(build.contains("purpur-26.3-2651.jar"));
|
||||
assertTrue(build.contains("https://api.purpurmc.org/v2/purpur/26.3/2651/download"));
|
||||
assertTrue(build.contains("0677c1febecfbc2e5b0a7f76abd647b70a1f38d3cbdf3dd6a82e401b4262a598"));
|
||||
assertFalse(build.contains("26.2.build.2618-stable"));
|
||||
assertFalse(build.contains("org.spigotmc:spigot-api"));
|
||||
String readme = Files.readString(Path.of("README.md"));
|
||||
assertTrue(readme.contains("Purpur 26.3 build 2651"));
|
||||
assertTrue(readme.contains("0677c1febecfbc2e5b0a7f76abd647b70a1f38d3cbdf3dd6a82e401b4262a598"));
|
||||
assertFalse(readme.contains("Purpur 26.2"));
|
||||
assertFalse(readme.contains("build 2618"));
|
||||
for (String workflow : new String[] {"ci.yml", "release.yml"}) {
|
||||
String content = Files.readString(Path.of(".gitea/workflows", workflow));
|
||||
assertTrue(content.contains("java-version: 25"));
|
||||
assertTrue(content.contains("purpur-trigger-spawn-"), workflow);
|
||||
assertFalse(content.contains("spigot-trigger-spawn-"), workflow);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,65 @@
|
||||
package games.dmg.triggerspawn;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
import static org.mockito.ArgumentMatchers.any;
|
||||
import static org.mockito.ArgumentMatchers.anyInt;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.never;
|
||||
import static org.mockito.Mockito.verify;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
import java.util.random.RandomGenerator;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.WorldBorder;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
final class SafeSpawnFinderTest {
|
||||
@Test
|
||||
void rejectsAConfiguredCenterOutsideTheWorldBorderBeforeInspectingBlocks() {
|
||||
World world = mock(World.class);
|
||||
WorldBorder border = mock(WorldBorder.class);
|
||||
when(world.getWorldBorder()).thenReturn(border);
|
||||
when(border.isInside(any(Location.class))).thenReturn(false);
|
||||
|
||||
var result = new SafeSpawnFinder().find(
|
||||
world,
|
||||
new SpawnLocation(10.0, 64.0, -10.0, 90.0F, 0.0F),
|
||||
0,
|
||||
RandomGenerator.getDefault());
|
||||
|
||||
assertTrue(result.isEmpty());
|
||||
verify(world, never()).getBlockAt(anyInt(), anyInt(), anyInt());
|
||||
}
|
||||
|
||||
@Test
|
||||
void returnsTheNearestClearSolidLocationInsideTheBorder() {
|
||||
World world = mock(World.class);
|
||||
WorldBorder border = mock(WorldBorder.class);
|
||||
Block ground = mock(Block.class);
|
||||
Block clear = mock(Block.class);
|
||||
when(world.getWorldBorder()).thenReturn(border);
|
||||
when(border.isInside(any(Location.class))).thenReturn(true);
|
||||
when(world.getMinHeight()).thenReturn(0);
|
||||
when(world.getMaxHeight()).thenReturn(128);
|
||||
when(world.getBlockAt(10, 63, -10)).thenReturn(ground);
|
||||
when(world.getBlockAt(10, 64, -10)).thenReturn(clear);
|
||||
when(world.getBlockAt(10, 65, -10)).thenReturn(clear);
|
||||
when(ground.getType()).thenReturn(Material.STONE);
|
||||
when(clear.getType()).thenReturn(Material.AIR);
|
||||
when(clear.isPassable()).thenReturn(true);
|
||||
|
||||
var result = new SafeSpawnFinder(material -> true, material -> false).find(
|
||||
world,
|
||||
new SpawnLocation(10.0, 64.0, -10.0, 90.0F, 10.0F),
|
||||
0,
|
||||
RandomGenerator.getDefault());
|
||||
|
||||
Location destination = result.orElseThrow();
|
||||
assertTrue(destination.getWorld() == world);
|
||||
assertTrue(destination.getX() == 10.5 && destination.getY() == 64.0 && destination.getZ() == -9.5);
|
||||
assertTrue(destination.getYaw() == 90.0F && destination.getPitch() == 10.0F);
|
||||
}
|
||||
}
|
||||
@@ -1,7 +1,12 @@
|
||||
package games.dmg.triggerspawn;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
import static org.mockito.ArgumentMatchers.any;
|
||||
import static org.mockito.ArgumentMatchers.contains;
|
||||
import static org.mockito.ArgumentMatchers.eq;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.never;
|
||||
import static org.mockito.Mockito.verify;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
@@ -9,12 +14,22 @@ import java.nio.file.Path;
|
||||
import java.time.Clock;
|
||||
import java.time.Instant;
|
||||
import java.time.ZoneOffset;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
import java.util.random.RandomGenerator;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Server;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.player.PlayerMoveEvent;
|
||||
import org.bukkit.event.player.PlayerQuitEvent;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
import org.bukkit.scheduler.BukkitScheduler;
|
||||
import org.bukkit.scheduler.BukkitTask;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.io.TempDir;
|
||||
|
||||
@@ -53,4 +68,94 @@ final class SpawnCommandTest {
|
||||
verify(player).sendMessage(contains("cannot use /spawn yet"));
|
||||
verify(player).sendMessage(contains("7h"));
|
||||
}
|
||||
|
||||
@Test
|
||||
void cancellationPathsOwnOnlyPendingTasksAndRetryTeleportsThenPersistsCooldown() throws Exception {
|
||||
Instant now = Instant.parse("2026-08-08T12:00:00Z");
|
||||
UUID playerId = UUID.randomUUID();
|
||||
UUID unrelatedPlayerId = UUID.randomUUID();
|
||||
Path stateFile = temporaryDirectory.resolve("state.yml");
|
||||
SpawnStateManager manager = SpawnStateManager.load(new YamlSpawnStateRepository(stateFile));
|
||||
manager.putPlayer(new PlayerState(
|
||||
playerId, "Alex", Set.of(BossType.WARDEN), Optional.empty(), false, Optional.empty()));
|
||||
PlayerState unrelated = new PlayerState(
|
||||
unrelatedPlayerId, "Steve", Set.of(BossType.WITHER), Optional.empty(), false, Optional.empty());
|
||||
manager.putPlayer(unrelated);
|
||||
|
||||
Plugin plugin = mock(Plugin.class);
|
||||
Server server = mock(Server.class);
|
||||
BukkitScheduler scheduler = mock(BukkitScheduler.class);
|
||||
when(plugin.getServer()).thenReturn(server);
|
||||
when(server.getScheduler()).thenReturn(scheduler);
|
||||
List<Runnable> countdowns = new ArrayList<>();
|
||||
List<BukkitTask> tasks = List.of(
|
||||
mock(BukkitTask.class),
|
||||
mock(BukkitTask.class),
|
||||
mock(BukkitTask.class),
|
||||
mock(BukkitTask.class));
|
||||
when(scheduler.runTaskTimer(eq(plugin), any(Runnable.class), eq(0L), eq(20L)))
|
||||
.thenAnswer(invocation -> {
|
||||
countdowns.add(invocation.getArgument(1));
|
||||
return tasks.get(countdowns.size() - 1);
|
||||
});
|
||||
|
||||
World world = mock(World.class);
|
||||
UUID worldId = UUID.randomUUID();
|
||||
Location start = new Location(world, 5.5, 70.0, 5.5);
|
||||
Location moved = new Location(world, 6.5, 70.0, 5.5);
|
||||
Location destination = new Location(world, 0.5, 65.0, 0.5, 90.0F, 0.0F);
|
||||
when(world.getUID()).thenReturn(worldId);
|
||||
when(world.getName()).thenReturn("overworld");
|
||||
when(world.getSpawnLocation()).thenReturn(new Location(world, 0.0, 64.0, 0.0));
|
||||
|
||||
Player player = mock(Player.class);
|
||||
when(player.getUniqueId()).thenReturn(playerId);
|
||||
when(player.getName()).thenReturn("Alex");
|
||||
when(player.getWorld()).thenReturn(world);
|
||||
when(player.getLocation()).thenReturn(start);
|
||||
when(player.teleport(destination)).thenReturn(true);
|
||||
|
||||
SafeSpawnFinder finder = mock(SafeSpawnFinder.class);
|
||||
when(finder.find(
|
||||
eq(world), any(SpawnLocation.class), eq(WorldSpawnState.DEFAULT_MAX_DISTANCE),
|
||||
any(RandomGenerator.class))).thenReturn(Optional.of(destination));
|
||||
PluginSettings settings = PluginSettings.from(new org.bukkit.configuration.MemoryConfiguration());
|
||||
SpawnCommand spawn = new SpawnCommand(
|
||||
plugin,
|
||||
manager,
|
||||
new AccessService(manager, settings),
|
||||
settings,
|
||||
new SpawnAreaService(manager),
|
||||
finder,
|
||||
Clock.fixed(now, ZoneOffset.UTC));
|
||||
|
||||
assertTrue(spawn.onCommand(player, mock(Command.class), "spawn", new String[0]));
|
||||
assertEquals(1, countdowns.size());
|
||||
spawn.onMove(new PlayerMoveEvent(
|
||||
player, start, new Location(world, 5.5, 70.0, 5.5, 180.0F, 20.0F)));
|
||||
verify(tasks.get(0), never()).cancel();
|
||||
spawn.onMove(new PlayerMoveEvent(player, start, moved));
|
||||
verify(tasks.get(0)).cancel();
|
||||
verify(player, never()).teleport(destination);
|
||||
|
||||
assertTrue(spawn.onCommand(player, mock(Command.class), "spawn", new String[0]));
|
||||
spawn.onQuit(new PlayerQuitEvent(player, "", PlayerQuitEvent.QuitReason.DISCONNECTED));
|
||||
verify(tasks.get(1)).cancel();
|
||||
|
||||
assertTrue(spawn.onCommand(player, mock(Command.class), "spawn", new String[0]));
|
||||
spawn.cancelAll();
|
||||
verify(tasks.get(2)).cancel();
|
||||
|
||||
assertTrue(spawn.onCommand(player, mock(Command.class), "spawn", new String[0]));
|
||||
assertEquals(4, countdowns.size());
|
||||
for (int tick = 0; tick < 4; tick++) {
|
||||
countdowns.get(3).run();
|
||||
}
|
||||
|
||||
verify(tasks.get(3)).cancel();
|
||||
verify(player).teleport(destination);
|
||||
PersistentState persisted = new YamlSpawnStateRepository(stateFile).load();
|
||||
assertEquals(Optional.of(now), persisted.players().get(playerId).lastSpawnUse());
|
||||
assertEquals(unrelated, persisted.players().get(unrelatedPlayerId));
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user