Overview
RunManager is the heart of the Soul Link Speedrun mod. It implements the Facade pattern to coordinate multiple services and manage the complete speedrun lifecycle, from world generation to victory or defeat.
Location: src/main/java/net/zenzty/soullink/server/run/RunManager.java
Class Structure
Dependencies
RunManager.java:45-59
The RunManager delegates to five specialized services, keeping each concern isolated:
- WorldService - Fantasy world creation/deletion
- TimerService - Run timer and action bar display
- SpawnFinder - Incremental spawn point search
- PlayerTeleportService - Safe player teleportation
Initialization
RunManager uses thread-safe singleton initialization:
RunManager.java:112-125
The volatile keyword ensures visibility across threads, while synchronized prevents race conditions during initialization.
Run Lifecycle
State Transitions
The run progresses through four states defined by theRunState enum:
RunState.java:6-17
Starting a Run
ThestartRun() method orchestrates the complex process of beginning a new speedrun:
RunManager.java:150-203
Tick Processing
Every server tick,RunManager processes the current state:
RunManager.java:210-238
The tick method:
- During
GENERATING_WORLD, processes incremental spawn search - When spawn found, transitions to
RUNNING - During
RUNNING, advances time and updates timer
Transition to Running
When spawn is found, the mod transitions to the active run:RunManager.java:256-315
Game End States
Game Over (Death)
When all players die (shared health reaches 0):RunManager.java:445-478
Victory (Ender Dragon)
When the Ender Dragon is defeated:RunManager.java:495-528
Key Methods
Late Join Handling
Players joining during an active run are automatically synced:RunManager.java:401-437
World Management
Helpers for checking and managing temporary worlds:RunManager.java:690-676
Manhunt Mode
In Manhunt mode,RunManager coordinates with ManhuntManager to:
Apply Head Start Effects
RunManager.java:323-337
This gives speedrunners a 30-second head start by blinding and immobilizing hunters while granting speed to runners.
Cleanup
When the server shuts down,RunManager performs cleanup:
RunManager.java:127-136
This ensures all temporary worlds are deleted and teams are cleaned up.