HRegen - Asynchronous Arena Regeneration with Cross-Server Redis Countdowns
HRegen is a high-performance, ultra-optimized arena regeneration plugin designed for Minecraft 1.21 to 1.21.11. Built natively for modern server architectures, it supports Paper, Leaf, and Purpur, alongside fully multi-threaded platforms such as Folia, Canvas, and ShreddedPaper.The plugin allows you to automatically restore designated regions (like BedWars, SkyWars, or build arenas) to a pristine state with zero tick spikes. Additionally, it features a built-in cross-server Redis-synchronized placeholder system. This allows lobbies and proxy servers to display live, identical countdown timers for your arenas without ever needing to load the arena chunks themselves.
Shared Network Placeholders
Unlike standard regional regeneration plugins, HRegen stores the next-regen deadline as an absolute timestamp on a centralized Redis clock.Each server on your network samples the central Redis time every 30 seconds, calculating and halving out network round-trip latency to correct for local clock drift. To render a placeholder, a server simply subtracts the current timestamp from the cached deadline—a simple, lock-free, in-memory calculation. As a result, scoreboards or tab-lists requesting these placeholders dozens of times per second across hundreds of players incur zero network overhead.
%hregen_arena1_time% -> 10m 5s (or 1s)
Reference Table
| Placeholder | Example Output | Description |
| %hregen_<arena>_time% | 10m 15s | Compact countdown. Customizable max-units. |
| %hregen_<arena>_time_short% | 10m | Short-form countdown (always displays a single time unit). |
| %hregen_<arena>_time_clock% | 10:15 | Digital clock display format. |
| %hregen_<arena>_seconds% | 615 | The remaining duration represented entirely in raw seconds. |
| %hregen_<arena>_status% | Regen in 10m | Customizable text layout populated from your messages.yml. |
| %hregen_<arena>_state% | IDLE | Current state: IDLE, REGENERATING, PAUSED, or MANUAL. |
| %hregen_<arena>_progress% / _bar% | 66 / ` | |
| %hregen_<arena>_interval% | 15m | The total configured duration between scheduled regenerations. |
| %hregen_<arena>_origin% | arena-1 | The specific server ID currently owning the active countdown lock. |
| %hregen_<arena>_last_ms% / _last_blocks% | 43 / 1892 | Duration (ms) and count of blocks replaced in the last run. |
| %hregen_soonest% / _soonest_time% | arena1 / 2m 5s | Identifies which arena is next in line to regenerate. |
| %hregen_count% / %hregen_synced% | 3 / true | The total active arena count and Redis synchronization status. |
High-Performance, Lag-Free Architecture
HRegen is designed from the ground up to prevent server lag:1. Delta-Only Block Tracking
HRegen tracks block changes incrementally, monitoring player blocks, explosions, pistons, water flow, fire, and crop growth. These are converted to highly compressed long formats and stored in a sharded, allocation-free data set (DirtySet). When a regeneration triggers, HRegen modifies only the blocks that actually changed, rather than pasting millions of blocks. The event listeners run at MONITOR priority and ignore cancelled events, processing coordinates in a fraction of a microsecond.2. Region-Safe Chunk Partitioning & Tick Budgeting
Modified blocks are cataloged by chunk and dispatched directly to the corresponding region thread that controls that chunk. Under Folia, different chunks regenerate simultaneously across different CPU cores. You can configure a strict blocks-per-tick limit; the engine executes writes up to this cap and then pauses, spreading the load across ticks to keep your MSPT low. Physics calculations are temporarily suspended during writes to prevent block update cascades.3. Native & FAWE Adaptive Writing
- On single-threaded Paper or Leaf servers with FastAsyncWorldEdit installed, HRegen routes block updates through FAWE's asynchronous chunk queue using optimal performance parameters (fastMode, disabling undo history tables, bypassing memory checks, and filling 16x16x16 volumes using direct region-set calls).
- On multi-threaded Folia servers (where FAWE cannot operate), the plugin automatically disables FAWE hooks and shifts to its native, region-safe multi-threaded engine.
4. Palette-Compressed Snapshots
Pristine arena snapshots are stored using 16x16x16 coordinate sections. Any sections composed entirely of a single block type (such as air above the arena) are compressed into a single char reference, saving up to 95% of memory. Snapshots are saved as gzipped .hrs files using vanilla block-state mappings, ensuring snapshots taken on version 1.21 load perfectly on 1.21.11.Multi-Server Synchronization Flow
To coordinate across multiple backend servers, HRegen uses a dynamic locking mechanism:- Distributed Lock Ownership: Exactly one server holds the Redis lock hregen
wner:<arena> at any given time (managed via SET ... NX PX and renewed every 5 seconds using Lua scripts).
- Automated Failovers: If the owner server crashes, its lock naturally expires after your configured scheduler-lock-seconds threshold. Another server hosting that arena automatically claims the lock and continues the countdown.
- Standalone Mode Fallback: If Redis goes offline, every server gracefully shifts to "standalone mode," running timers locally to keep games running.
- Lobby Deployments: If a server doesn't have the world file for an arena, it simply skips the block-replacement steps. It still syncs the countdown via Redis, meaning lobbies only need the JAR and a connection to the shared Redis database to display placeholders.
Commands and Permissions
All commands require the hregen.admin permission node.Available Aliases: /hrg, /arenaregen.
| Command | Description |
| /hregen wand | Gives the selection wand (Left-click for Corner 1, Right-click for Corner 2). |
| /hregen pos1 / pos2 | Sets a selection corner at your current standing position. |
| /hregen create <id> [interval] | Saves a snapshot of the selected area and initiates a timer (e.g., 15m or manual). |
| /hregen save <id> | Captures the current state of the arena as the new pristine snapshot template. |
| /hregen regen <id> [full] | Triggers a regeneration across all servers. Adding full forces a complete block-by-block comparison. |
| /hregen list | Displays a list of all arenas configured across the entire network. |
| /hregen info <id> | Displays coordinate bounds, snapshot sizes, modified block counts, and timing statistics. |
| /hregen interval <id> <time> | Changes the scheduled interval of an arena (e.g., /hregen interval arena1 20m). |
| /hregen settime <id> <time> | Manually overrides the current active countdown timer (e.g., 30s). |
| /hregen pause / resume <id> | Pauses or resumes the shared network countdown timer. |
| /hregen setspawn <id> | Sets the evacuation spawn point where players are sent before a regeneration. |
| /hregen enable / disable <id> | Toggles the active state of an arena. |
| /hregen remove <id> | Deletes the arena configuration and removes its snapshot file. |
| /hregen status | Displays the current engine, host platform, Redis connection health, and clock drift. |
| /hregen reload | Reloads config.yml and language files on the fly. |
