rand-rspwn
rand-rspwn is a Folia-native plugin for Minecraft servers. It randomizes fallback respawns around a configured center.
In this description, "vanilla" means the default behavior of Minecraft.
Behavior
The plugin does these actions:
- The plugin randomizes the first join of a player during the asynchronous spawn-selection phase of Folia and Paper. It does this only when you enable
randomize-first-join. - The plugin prepares a random fallback location for a death without a personal respawn location. The plugin does the preparation asynchronously.
- The plugin verifies known bed markers and respawn-anchor markers from the block data on the region of each marker. The plugin does the verification asynchronously.
- The plugin preserves
/spawnpoint, legacy, and other unmarked custom respawn locations. - The plugin installs a ready candidate as a temporary forced respawn location on the entity scheduler of the player.
- On Paper,
PlayerRespawnEventcan apply a ready candidate synchronously before the final respawn teleport. - On Folia, the region-threaded path can start before a candidate is ready. In this case, the vanilla behavior remains.
- The plugin samples candidates uniformly by area inside a circle.
- The plugin loads or generates candidate chunks asynchronously.
- The plugin verifies surface blocks, clearance, configured hazards, world borders, and hard collisions.
- If no candidate succeeds, the player remains at the vanilla respawn location.
The default behavior matches the public description of 2B2T. The plugin does not copy the private implementation of 2B2T.
Center and radius
The default center is the origin of the configured world. The origin is (0, 0). This matches the public statement of 2B2T that players spawn within 2,048 blocks of the world origin.
Set center: world-spawn to use the location of /setworldspawn as the center.
2B2T does not publish its exact sampling and safety algorithm. The plugin does not copy its distribution or its deliberately hazardous spawn environment. The plugin approximates bed stand-up validity with public block data. The plugin preserves ambiguous personal locations. It does not change them. The plugin has no live Folia integration test. Server-side respawn ordering remains a runtime validation gap.
Build
The project uses the stable Folia 26.1.2 API by default. To build and test the plugin:
./gradlew clean test
To build against the Folia 26.2 beta API:
./gradlew clean test -PfoliaApiVersion=26.2.build.1-beta
The same source set works for both API lines. The plugin does not use NMS or the traditional Bukkit scheduler.
- First joins use
AsyncPlayerSpawnLocationEvent. - Deaths prepare candidates from
PlayerDeathEvent. - The plugin tries to preinstall candidates through
EntityScheduler. This must happen before Folia's region-threaded respawn operation captures the respawn configuration of the player. - The plugin keeps
PlayerRespawnEventas a compatibility hook for the normal Paper path. Folia's custom death path can bypass it. - The plugin does not use
PlayerPostRespawnEvent. The event is too late. Folia can also bypass it.
The build requests Java 25. Java 25 matches the Folia 26.1.x and 26.2.x server builds. The Foojay toolchain resolver of Gradle can download Java 25 if you do not have Java 25 locally.
Configuration
The plugin copies config.yml on first startup. The important settings are:
world-name: world
center: origin
radius: 2048
max-attempts: 12
search-timeout-millis: 5000
generate-chunks: true
randomize-first-join: true
preserve-personal-spawn: true
search-timeout-millis limits how long the plugin can load chunks and check candidates. It applies to first joins and fallback respawns.
If the search times out or uses all its attempts, the vanilla spawn remains in effect. If the player presses respawn before the plugin installs the candidate, the vanilla spawn also remains in effect. The respawn request from the client can arrive before the plugin completes the preparation. Without a server-side respawn-flow integration, death randomization is best effort.
generate-chunks: true makes the feature work on newly generated areas. It can add chunk-generation work during respawn. On a pre-generated anarchy map, set it to false if you do not want generation at death time.