rand-rspwn
rand-rspwn 是一款原生支持 Folia 的 Minecraft 服务器插件。它会在配置的圆心周围随机化回退重生点。
在此说明中,“原版”(vanilla)指 Minecraft 的默认行为。
行为机制
该插件执行以下操作:
- 在 Folia 和 Paper 的异步出生点选择阶段,插件会随机化玩家的首次加入位置。仅在启用
randomize-first-join 时生效。
- 为玩家在没有个人重生点时的死亡情况准备一个随机的回退位置。插件以异步方式执行此准备工作。
- 验证每个标记所在区域的区块数据中的已知床标记和重生锚标记。插件以异步方式执行此验证。
- 保留
/spawnpoint、旧版以及其他未标记的自定义重生位置。
- 将准备好的候选重生点作为临时强制重生点安装到玩家的实体调度器上。
- 在 Paper 上,
PlayerRespawnEvent 可以在最终重生传送之前同步应用已准备好的候选重生点。
- 在 Folia 上,区域线程路径可能在候选重生点就绪前启动。在这种情况下,原版行为保持不变。
- 插件在圆形区域内按面积均匀采样候选重生点。
- 插件以异步方式加载或生成候选重生点所在的区块。
- 插件验证地表方块、通行空间、配置的危险区域、世界边界以及硬性碰撞。
- 如果没有候选重生点成功,玩家将保持在原版的重生位置。
默认行为与 2B2T 的公开描述一致。该插件并未复制 2B2T 的内部实现。
圆心与半径
默认圆心为配置世界的原点 (0, 0)。这与 2B2T 公开的声明一致,即玩家在世界原点 2,048 格内出生。
设置 center: world-spawn 可使用 /setworldspawn 的位置作为圆心。
2B2T 并未公开其确切的采样和安全算法。该插件并未复制其分布模式或故意制造的危险出生环境。该插件利用公开的区块数据近似判断床站立的有效性。该插件保留模糊的个人重生位置,且不对其进行修改。该插件没有实时的 Folia 集成测试。服务器端重生顺序仍存在运行时验证空白。
构建
项目默认使用稳定的 Folia 26.1.2 API。要构建并测试该插件:
./gradlew clean test
若要针对 Folia 26.2 beta API 进行构建:
./gradlew clean test -PfoliaApiVersion=26.2.build.1-beta
同一源码集适用于这两条 API 分支。该插件不使用 NMS(非官方 Mojang 类)或传统的 Bukkit 调度器。
- 首次加入使用
AsyncPlayerSpawnLocationEvent。
- 死亡事件通过
PlayerDeathEvent 准备候选重生点。
- 插件尝试通过
EntityScheduler 预安装候选重生点。这必须在 Folia 的区域线程重生操作捕获玩家重生配置之前完成。
- 插件保留
PlayerRespawnEvent 作为兼容正常 Paper 路径的钩子。Folia 的自定义死亡路径可能会绕过它。
- 插件不使用
PlayerPostRespawnEvent。该事件发生得太晚。Folia 也可能绕过它。
构建需要 Java 25。Java 25 与 Folia 26.1.x 和 26.2.x 服务器版本相匹配。如果你本地没有安装 Java 25,Gradle 的 Foojay 工具链解析器可以下载 Java 25。
配置
插件在首次启动时会复制 config.yml。重要设置如下:
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 限制插件加载区块和检查候选重生点的最长时间。它适用于首次加入和回退重生。
如果搜索超时或用尽所有尝试次数,原版出生点将继续生效。如果玩家在插件安装候选重生点之前按下重生按钮,原版出生点也将继续生效。来自客户端的重生请求可能在插件完成准备工作之前到达。由于缺乏服务器端重生流程集成,死亡随机化仅是尽力而为。
generate-chunks: true 使功能在新生成的区域中生效。它可能会在重生期间增加区块生成工作。对于预生成的混乱地图(anarchy map),如果你不希望死亡时生成区块,请将其设置为 false。
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,
PlayerRespawnEvent can 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
PlayerRespawnEvent as 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.
评论 0
登录后参与评分
还没有评论,来抢沙发吧