HimDungeons
让房间决定它们如何连接。
HimDungeons 是一个适用于 Paper / Spigot / Bukkit 服务器的程序化地牢生成器,无需 WorldEdit。它在运行时构建地牢世界,并使用双向门锚算法将预制房间结构体拼接在一起。任何大小、任何形状、任何门位置的房间都可以连接——只要它们的门面对面相接即可。
为什么选择 HimDungeons?
大多数地牢插件强制你的房间遵循网格布局:统一的大小、固定在墙壁上的门、每个房间朝向相同的方向。你花几个小时建造一个 L 形房间,却发现门必须位于北墙的中点——蓝图就此报废。
HimDungeons 采取了不同的方法。每个房间声明其门的位置和朝向。生成器会找到正确的旋转和偏移量来连接任意两个房间。你建造你想要的;算法处理其余部分。
| 功能 |
典型的地牢插件 |
HimDungeons |
| 房间大小 |
必须统一 |
任意大小 |
| 房间形状 |
多为矩形 |
任意形状(L 形、T 形、十字形、不规则) |
| 门位置 |
固定的墙壁位置 |
任意坐标 |
| 门大小 |
1×1 或固定 |
任意大小(1×1、3×3、5×5 拱门) |
| 垂直连接 |
很少支持 |
原生 3D (y+ / y-) |
| 房间文件夹布局 |
扁平,强制前缀 |
任意子目录深度 |
| WorldEdit |
硬性依赖 |
无依赖 |
| 异步加载 |
经常阻塞主线程 |
Tick 批量处理,TPS 安全 |
核心算法:双向门锚定
每个房间在 _door.yml 文件中声明其门:
doors:
- {x: 0, y: 1, z: 5, facing: "z-", type: "default", weight: 10}
- {x: 12, y: 1, z: 3, facing: "x+", type: "default", weight: 10}
- {x: 5, y: 0, z: 5, facing: "y-", type: "stairs", weight: 5}
在生成过程中,算法从当前房间获取一个可用的门 A(世界位置 P1,朝向 D1)。然后尝试放置候选房间 B 的每个门 (P2, D2),并测试所有四种旋转。当且仅当满足以下条件时,一对门连接成功:
P1 + D1 == P2 AND P2 + D2 == P1
从门 A 向外走一格正好落在门 B 上,从门 B 向外走一格正好落在门 A 上。两扇门相对而立,相互接触,且指向相反的方向。
这解锁了:
- 任意房间大小 —— 一个 3×3 的储藏室可以直接紧邻一个 50×50 的首领大厅,只要它们的门对齐即可。
- 任意房间形状 —— L 形、十字形、环形、不规则多边形均有效。算法只关心门的坐标和朝向,而不关心房间的轮廓。
- 任意门位置 —— 门不需要位于墙壁中心。角落的门完全合法。
- 任意门大小 —— 1×1 的门和 3×3 的拱门可以连接,因为算法匹配的是坐标和方向,而不是几何开口。
- 自动四向旋转 —— 候选房间会被旋转 0°、90°、180° 和 270° 直到门匹配。你无需为四个方向准备四种结构体变体。
- AABB 碰撞检测 —— 感知旋转的边界框确保新放置的房间永远不会与现有房间重叠。
门类型门控
门支持 type 字段。楼梯门只能连接到楼梯门,宏伟拱门只能连接到宏伟拱门,备用门只能连接到备用门。这允许你强制执行语义约束,例如“楼梯必须向下”或“宏伟拱门总是通向首领大厅”。
原生 3D 拼接
大多数地牢插件是 2D 的:房间仅在 XZ 平面上拼接,垂直移动意味着切换世界。HimDungeons 支持 y+(向上)和 y-(向下)的门朝向。当 y- 门连接到 y+ 门时,新房间被放置在当前房间下方,形成真正的垂直堆叠。
你可以建造:
- 多层地牢 —— 地面入口 → 地下墓穴 → 深层巢穴,使用一套结构体。
- 塔楼 —— 螺旋上升,每层一个
y+ 门。
- 垂直难度梯度 —— 玩家深入得越深,首领越强,由
structureChoose 权重控制。
垂直门在 Y 轴旋转下是不变的,因此你只需要一个结构体用于上下连接。
自由文件组织
房间文件夹会被递归扫描。房间可以位于任何深度,路径本身即为唯一的房间标识符:
plugins/HimDungeons/my_dungeon/rooms/
├── chapter1/
│ ├── start_entrance.schem
│ ├── combat/
│ │ ├── sword_fight.schem
│ │ └── ambush.schem
│ └── boss_chapter1.schem
├── chapter2/
│ └── ...
└── fallback/
└── sealed_wall.schem
chapter1/combat/sword_fight 是配置中的房间名称。按章节、难度、主题或作者组织——由你决定。大型地牢保持整洁,版本控制易于审查。
无需 WorldEdit
HimDungeons 自带 SpongeSchematicReader 和 SpongeSchematicWriter(基于 Querz NBT 库),用于支持 Sponge Schematic v2 和 v3。方块旋转使用 Bukkit 原生的 BlockData.rotate(StructureRotation)。区域选择使用创造模式下的木镐作为操作员——无需外部插件。
这很重要:
- 插件 jar 包大约为 3.5 MB(NBT 和 SQLite 原生库已阴影打包),远小于 WorldEdit 堆栈。
- 服务器升级无需等待 WorldEdit 兼容性。
- WorldEdit 和 HimDungeons 不会互相拖累。
- 结构体格式可全局配置(
schematic.readFormat: auto | sponge_v2 | sponge_v3)。
从 WorldEdit 迁移?将现有的 .schem 文件放入 rooms/ 中——它们可以直接读取,因为 WorldEdit 默认以 Sponge v2 或 v3 格式保存。
异步 IO 和 Tick 批量粘贴
WorldEdit 粘贴是同步的。一个 30×20×30 的房间可能会使低端服务器停滞 100–500 毫秒。HimDungeons 将工作分为三个阶段:
- Async — 读取并解析
.schem 文件。
- Async — 预计算每个方块位置及旋转后的
BlockData。
- 主线程,按刻批处理 — 每刻放置一批可配置的方块数,然后让出控制权。
// Tunable in AsyncPaster.java
private static final int BLOCKS_PER_TICK = 2000;
在粘贴大型房间时,服务器仍可正常运行。保存也是异步的:主线程读取方块数据,异步线程写入文件。
完整生命周期与崩溃安全性
玩家状态转换由单一的 DungeonSessionService 状态机处理:
[Overworld] ──enter──► [In Dungeon] ──finish──► [Overworld] (恢复物品栏 + 奖励 + 胜利次数++)
│
├── death ──► [In Dungeon] (在检查点或出生点重生,不操作物品栏)
├── /dg leave ──► [Overworld] (恢复物品栏 + 5分钟清理计时器)
├── quit ──► [Offline] (立即恢复物品栏,5分钟重新加入窗口)
└── join ──► < 5分钟: 重新进入 | ≥ 5分钟: 留在主世界
数据存储分为两个独立的系统:
| 数据 |
位置 |
格式 |
| 胜利计数 |
plugins/HimDungeons/<dungeon>/stats.yml |
YAML(人类可读,可编辑) |
| 物品栏备份 |
plugins/HimDungeons/backup.db |
SQLite(WAL 模式,synchronous=NORMAL) |
恢复物品栏绝不会影响胜利统计,因为两者存储在不同的文件中。
崩溃恢复: 服务器启动时,每个 ACTIVE 状态的备份行会被标记为 PENDING_RESTORE。玩家加入时,备用恢复机制会运行并删除该行。kill -9 或硬断电不会丢失已提交的备份。
死亡行为: keepInventory 决定是否在死亡时掉落物品(原版游戏规则)。插件仅选择重生位置:优先检查点,其次是地牢出生点。死亡永远不会触发物品栏恢复。
游戏内管理 GUI
房间、门、箱子、出生点和检查点以及配置值均可通过游戏内 GUI 进行编辑。无需手动编辑 YAML。批量配置编辑功能允许您一次性修改所有地牢中的某个键值。
命令
| 命令 |
权限 |
描述 |
/dg start [dungeon] [mode] |
himdungeons.start |
开始一个地牢。模式:single、multi、party |
/dg leave |
himdungeons.leave |
离开当前地牢 |
/dg edit [dungeon] |
himdungeons.admin |
打开管理 GUI |
/dg create <dungeon> |
himdungeons.admin |
创建地牢文件夹结构 |
/dg reload |
himdungeons.admin |
重新加载全局配置 |
以及更多...
multi 模式会将 3 格范围内潜行的附近玩家纳入其中。party 模式需要 Parties 插件支持。
配置示例
dungeonInstance:
minRoomAmount: 5
maxRoomAmount: 12
dfsMaxDeep: 8
startToBossRoomAmmount: "10 10"
allowRoomReuse: false
allowDoorReuse: false
useAabb: true
useBfsCheck: false
disconnectedRoomDistance: 0
keepInventory: false
deepCloneInventory: false
time: 0
dungeonTime: 1200
weather: clear
difficulty: normal
lobby: "world,0,64,0,0,0"
bossType: ["zombie"]
bossNbt: ["{Health:100.0f}"]
rewards:
vault: {}
playerPoints: {}
consoleCommands: []
keepInventory 和 deepCloneInventory 是独立的。启用 keepInventory 可实现“地牢内不掉落物品”。启用 deepCloneInventory 可实现“进入/退出时的物品栏隔离”。两者可以同时存在。
兼容性
- 服务器: Bukkit 1.18+(推荐 1.21.3+),Spigot、Bukkit、Paper Purpur。
- Java: 25+(最新版本支持 21+)
- 软依赖(均为可选): Vault(入场费、奖励金钱)、PlaceholderAPI(占位符)、Parties(组队模式)、Slimefun(物品使用限制)、MythicMobs(自定义 Boss)
当缺少这些软依赖时,插件会优雅降级。
已知限制
- 仅支持 Sponge Schematic v2 和 v3。不支持传统的 MCEdit
.schematic 文件。
- 地牢世界使用虚空生成器——没有自然地形或生物。
- 捆绑的 SQLite 原生库仅覆盖 Linux x86_64 和 Windows x86_64。ARM 和 macOS 用户必须在
pom.xml 中调整 shade 排除项。
- 发生硬崩溃后,世界文件夹(
dungeon_<name>_<timestamp>)会保留在磁盘上,必须手动清理。计划添加自动扫描清理功能。
HimDungeons
Let the rooms decide how they connect.
HimDungeons is a procedural dungeon generator for Paper / Spigot / Bukkit servers that does not require WorldEdit. It builds dungeon worlds at runtime and stitches prefabricated room schematics together using a bidirectional door-anchor algorithm. Rooms of any size, any shape, and any door position can connect — as long as their doors meet face-to-face.
Why HimDungeons?
Most dungeon plugins force your rooms into a grid: uniform sizes, doors on fixed walls, every room facing the same direction. You spend hours building an L-shaped room, then discover the door must sit on the north wall’s midpoint — and the blueprint is dead.
HimDungeons takes a different approach. Each room declares where its doors are and which way they face. The generator finds the correct rotation and offset to connect any two rooms. You build what you want; the algorithm handles the rest.
| Capability |
Typical dungeon plugins |
HimDungeons |
| Room size |
Must be uniform |
Any size |
| Room shape |
Mostly rectangular |
Any shape (L, T, cross, irregular) |
| Door position |
Fixed wall positions |
Any coordinate |
| Door size |
1×1 or fixed |
Any size (1×1, 3×3, 5×5 arches) |
| Vertical connections |
Rarely supported |
Native 3D (y+ / y-) |
| Room folder layout |
Flat, forced prefixes |
Any subdirectory depth |
| WorldEdit |
Hard dependency |
No dependency |
| Async loading |
Often blocks main thread |
Tick-batched, TPS-safe |
Core Algorithm: Bidirectional Door Anchoring
Every room declares its doors in a _door.yml file:
doors:
- {x: 0, y: 1, z: 5, facing: "z-", type: "default", weight: 10}
- {x: 12, y: 1, z: 3, facing: "x+", type: "default", weight: 10}
- {x: 5, y: 0, z: 5, facing: "y-", type: "stairs", weight: 5}
During generation, the algorithm takes an available door A from the current room (world position P1, facing D1). It then tries to place each door (P2, D2) of a candidate room B, testing all four rotations. A pair connects if and only if:
P1 + D1 == P2 AND P2 + D2 == P1
Walking one block out from door A lands exactly on door B, and walking one block out from door B lands exactly on door A. The two doors face each other, touch, and point in opposite directions.
What this unlocks:
- Any room size — a 3×3 storage closet can sit directly beside a 50×50 boss hall, as long as their doors line up.
- Any room shape — L-shaped, cross-shaped, ring-shaped, irregular polygons all work. The algorithm only cares about door coordinates and facings, not the room’s silhouette.
- Any door position — doors do not need to be centered on a wall. A corner door is perfectly valid.
- Any door size — a 1×1 door and a 3×3 arch can connect, because the algorithm matches coordinates and directions, not the geometric opening.
- Automatic 4-way rotation — candidate rooms are rotated 0°, 90°, 180°, and 270° until doors match. You never need to prepare four schematic variants for four directions.
- AABB collision detection — rotation-aware bounding boxes guarantee that newly placed rooms never overlap existing ones.
Door type gating
Doors support a type field. Stair doors only connect to stair doors, grand arches only to grand arches, fallback doors only to fallback doors. This lets you enforce semantic constraints such as “stairs must lead downward” or “a grand arch always leads to a boss hall.”
Native 3D Stitching
Most dungeon plugins are 2D: rooms stitch only on the XZ plane, and vertical movement means switching worlds. HimDungeons supports y+ (up) and y- (down) door facings. When a y- door connects to a y+ door, the new room is placed below the current one, forming a genuine vertical stack.
What you can build:
- Multi-layer dungeons — surface entrance → underground crypt → deep lair, using one schematic set.
- Towers — spiral upward, one
y+ door per floor.
- Vertical difficulty gradients — the deeper the player goes, the stronger the boss, controlled by
structureChoose weights.
Vertical doors are invariant under Y-axis rotation, so you only need one schematic for up/down connections.
Free File Organization
Room folders are scanned recursively. Rooms can live at any depth, and the path itself is the unique room identifier:
plugins/HimDungeons/my_dungeon/rooms/
├── chapter1/
│ ├── start_entrance.schem
│ ├── combat/
│ │ ├── sword_fight.schem
│ │ └── ambush.schem
│ └── boss_chapter1.schem
├── chapter2/
│ └── ...
└── fallback/
└── sealed_wall.schem
chapter1/combat/sword_fight is the room’s name in configuration. Organize by chapter, difficulty, theme, or author — your choice. Large dungeons stay clean, and version control stays reviewable.
No WorldEdit Required
HimDungeons ships with its own SpongeSchematicReader and SpongeSchematicWriter (built on the Querz NBT library) for Sponge Schematic v2 and v3. Block rotation uses Bukkit’s native BlockData.rotate(StructureRotation). Region selection uses a wooden pickaxe in creative mode as an operator — no external plugin needed.
Why this matters:
- The plugin jar is roughly 3.5 MB (NBT and SQLite native libraries shaded in), far smaller than the WorldEdit stack.
- Server upgrades do not wait on WorldEdit compatibility.
- WorldEdit and HimDungeons cannot drag each other down.
- Schematic format is configurable globally (
schematic.readFormat: auto | sponge_v2 | sponge_v3).
Migrating from WorldEdit? Drop your existing .schem files into rooms/ — they read directly, because WorldEdit saves in Sponge v2 or v3 by default.
Async IO and Tick-Batched Pasting
WorldEdit pasting is synchronous. A 30×20×30 room can stall a low-end server for 100–500 ms. HimDungeons splits the work into three stages:
- Async — read and parse the
.schem file.
- Async — precompute every block position and rotated
BlockData.
- Main thread, tick-batched — place a configurable batch of blocks per tick, then yield.
// Tunable in AsyncPaster.java
private static final int BLOCKS_PER_TICK = 2000;
The server keeps running normally while a large room is pasted. Saving is asynchronous too: the main thread reads block data, and the async thread writes the file.
Complete Lifecycle and Crash Safety
Player transitions are handled by a single DungeonSessionService state machine:
[Overworld] ──enter──► [In Dungeon] ──finish──► [Overworld] (restore inventory + rewards + wins++)
│
├── death ──► [In Dungeon] (respawn at checkpoint or spawn, no inventory op)
├── /dg leave ──► [Overworld] (restore inventory + 5-min cleanup timer)
├── quit ──► [Offline] (restore inventory immediately, 5-min rejoin window)
└── join ──► < 5 min: re-enter | ≥ 5 min: stay in overworld
Data storage is split into two independent systems:
| Data |
Location |
Format |
| Win counts |
plugins/HimDungeons/<dungeon>/stats.yml |
YAML (human-readable, editable) |
| Inventory backups |
plugins/HimDungeons/backup.db |
SQLite (WAL, synchronous=NORMAL) |
Restoring an inventory can never affect win statistics, because the two live in separate files.
Crash recovery: on server startup, every ACTIVE backup row is marked PENDING_RESTORE. On player join, the fallback restore runs and deletes the row. A kill -9 or hard power loss never loses committed backups.
Death behavior: keepInventory decides whether items drop on death (vanilla gamerule). The plugin only picks the respawn location: checkpoint first, then dungeon spawn. Death never triggers an inventory restore.
In-Game Admin GUI
Rooms, doors, chests, spawn points, checkpoints, and configuration values are all editable through an in-game GUI. No hand-editing YAML required. Batch config editing lets you modify a key across every dungeon at once.
Commands
| Command |
Permission |
Description |
/dg start [dungeon] [mode] |
himdungeons.start |
Start a dungeon. Modes: single, multi, party |
/dg leave |
himdungeons.leave |
Leave the current dungeon |
/dg edit [dungeon] |
himdungeons.admin |
Open the admin GUI |
/dg create <dungeon> |
himdungeons.admin |
Create a dungeon folder structure |
/dg reload |
himdungeons.admin |
Reload global configuration |
and more...
multi mode adds nearby sneaking players within 3 blocks. party mode requires the Parties plugin.
Configuration Sample
dungeonInstance:
minRoomAmount: 5
maxRoomAmount: 12
dfsMaxDeep: 8
startToBossRoomAmmount: "10 10"
allowRoomReuse: false
allowDoorReuse: false
useAabb: true
useBfsCheck: false
disconnectedRoomDistance: 0
keepInventory: false
deepCloneInventory: false
time: 0
dungeonTime: 1200
weather: clear
difficulty: normal
lobby: "world,0,64,0,0,0"
bossType: ["zombie"]
bossNbt: ["{Health:100.0f}"]
rewards:
vault: {}
playerPoints: {}
consoleCommands: []
keepInventory and deepCloneInventory are independent. Enable only keepInventory for “no drops in dungeon.” Enable only deepCloneInventory for “inventory isolation on enter/exit.” Both can coexist.
Compatibility
- Server: Bukkit 1.18+ (1.21.3+ recommended), Spigot, Bukkit, Paper Purpur.
- Java: 25+ (The newest version allows 21+)
- Soft dependencies (all optional): Vault (entry fees, reward money), PlaceholderAPI (placeholders), Parties (party mode), Slimefun (item usage gating), MythicMobs (custom bosses)
All soft dependencies degrade gracefully when absent.
Known Limitations
- Only Sponge Schematic v2 and v3 are supported. Legacy MCEdit
.schematic files are not supported.
- Dungeon worlds use a void generator — no natural terrain or mobs.
- Bundled SQLite native libraries cover Linux x86_64 and Windows x86_64 only. ARM and macOS users must adjust the shade exclusions in
pom.xml.
- After a hard crash, world folders (
dungeon_<name>_<timestamp>) remain on disk and must be cleaned manually. Auto-scan cleanup is planned.
评论 0
登录后参与评分
还没有评论,来抢沙发吧