How sybsuper/terradevserver works
1. System role
- This repository is a standalone Kotlin/JVM Minecraft dev server for Terra packs.
- Its purpose is to run a local server, load a Terra pack from a dev/ folder, and support rapid iteration without restarting the server.
2. Top-level runtime
- Main.kt is the entry point and likely wires together the server bootstrap, configuration, world creation, command registration, and module activation.
- The project is built as a single Gradle application, packaged into a runnable jar.
3. Configuration boundary
- Config.kt owns server settings such as bind address, port, pack folder, world seed, MOTD, enabled commands, and feature flags.
- The config file is persisted in the server root and acts as the main switchboard for which subsystems are active.
4. World and pack lifecycle
- WorldCreator.kt appears to create or initialize the Minecraft world/instance from the Terra pack.
- UpdateDevPack.kt is the central reload path: it swaps in updated pack content from disk and triggers downstream updates.
- events/PackPostLoadEvent.kt marks the completion of pack loading so other systems can react after the new pack is ready.
5. Hot-reload and filesystem watching
- modules/WatchFolders.kt is the filesystem watcher that detects changes inside the dev pack directory.
- The flow is: file change in dev/ → pack update/reload → pack post-load event → world/player/module adjustments.
- This is the core mechanism behind the repository’s “hot-reloading” feature.
6. Player session and view synchronization
- modules/SyncPositions.kt keeps players aligned so multiple clients can be used as side-by-side “before/after” views.
- modules/PlayerCycleTarget.kt likely manages which player is used as the reference when cycling between reload views.
- PlayerLogger.kt suggests join/leave tracking to support these player coordination features.
7. Biome registry handling
- modules/BiomeRegistryFix.kt and commands/ReregisterBiomes.kt address a key Terra dev problem: adding new biomes without forcing a full server/world restart.
- The architecture here is explicitly designed to handle biome-registry changes during pack reloads, which is why there is also a config flag for fixing biome disconnects.
- events/PrePlayerSendNewInstanceForPackEvent.kt indicates player transfer/reconnect handling when the server needs to move clients to a refreshed pack instance.
8. Instance cleanup and server health
- modules/RemoveDeadInstances.kt is responsible for cleaning up stale world instances created by previous pack loads.
- This keeps the reload cycle from accumulating unused world state and helps the server remain stable during repeated edits.
9. Command subsystem
- commands/CommandManager.kt is the command registry and dispatcher.
- Each command implements commands/ICommand.kt, so command behavior is modular and can be enabled/disabled through config.
- The built-in commands are:
- Reload for manual pack reloads,
- Locate for biome lookup in the current world,
- Teleport for direct movement,
- ReregisterBiomes for biome-registry refreshes.
10. Module subsystem
- modules/ModuleManager.kt is the feature-toggle layer that starts/stops optional behaviors based on configuration.
- The modules are deliberately separated from commands: commands are user-triggered actions, while modules are always-on or config-driven server behaviors.
11. MOTD and server presentation
- modules/Motd.kt controls the server-list display name, which is part of the server’s external face to Minecraft clients.
- This is a small but distinct presentation subsystem separate from pack loading and gameplay mechanics.
12. Important architectural flow
- The main loop is: boot server → load config → create world from dev pack → register commands/modules → watch for file changes → reload pack → update players/instances/biomes.
- The repository is organized around that lifecycle, with events used as boundaries so pack loading, player handling, and biome fixes remain loosely coupled.
Main entry points: Main.kt Main · ModuleManager.kt Module Manager · CommandManager.kt Command Manager · PackPostLoadEvent.kt Pack Post Load
Components 20
Runtime
Server bootstrap and core lifecycle
Pack Reload
Dev pack loading, world creation, and reload events
- World Creator · Creates or initializes the Minecraft world from the Terra dev pack.
src/main/kotlin/WorldCreator.kt - Update Pack · Central reload path that swaps updated pack content into the running server.
src/main/kotlin/UpdateDevPack.kt - Pack Post Load · Signals that a pack has finished loading so downstream systems can react.
src/main/kotlin/events/PackPostLoadEvent.kt - Watch Folders · Monitors the dev pack directory and triggers reloads on file changes.
src/main/kotlin/modules/WatchFolders.kt
Player Sync
Player coordination and instance transitions
- Pre Send Event · Raised before moving a player into a refreshed instance for the updated pack.
src/main/kotlin/events/PrePlayerSendNewInstanceForPackEvent.kt - Sync Positions · Keeps multiple players aligned for side-by-side comparison.
src/main/kotlin/modules/SyncPositions.kt - Cycle Target · Tracks the reference player used when cycling views.
src/main/kotlin/modules/PlayerCycleTarget.kt - Player Logger · Tracks player join and leave activity for coordination flows.
src/main/kotlin/PlayerLogger.kt
Features
Optional modules and service behaviors
- Module Manager · Starts and stops config-driven runtime modules.
src/main/kotlin/modules/ModuleManager.kt - Biome Fix · Handles biome registry changes without requiring a full restart.
src/main/kotlin/modules/BiomeRegistryFix.kt - Remove Dead · Deletes stale world instances left behind by previous reloads.
src/main/kotlin/modules/RemoveDeadInstances.kt - MOTD · Controls the server-list display text seen by clients.
src/main/kotlin/modules/Motd.kt
Commands
User-triggered actions and command dispatch
- Command Manager · Registers and dispatches built-in commands.
src/main/kotlin/commands/CommandManager.kt - ICommand · Shared interface implemented by all commands.
src/main/kotlin/commands/ICommand.kt - Reload · Manual trigger for pack reloads.
src/main/kotlin/commands/Reload.kt - Locate · Finds a biome or target in the current world.
src/main/kotlin/commands/Locate.kt - Teleport · Moves a player directly to a chosen location.
src/main/kotlin/commands/Teleport.kt - Reregister Biomes · Refreshes biome registration during pack reloads.
src/main/kotlin/commands/ReregisterBiomes.kt
Connections 24
- Main → Config: loads · Boot reads persisted server settings before enabling subsystems.
- Main → World Creator: creates world · Startup initializes the world from the dev pack.
- Main → Module Manager: starts modules · Main activates optional behaviors from configuration.
- Main → Command Manager: registers commands · Main wires the command subsystem during boot.
- Main → Watch Folders: enables watch · Boot turns on filesystem watching for dev-pack changes.
- Main → MOTD: configures · Main applies server presentation settings.
- Watch Folders → Update Pack: triggers · File edits initiate the reload pipeline.
- Update Pack → Pack Post Load: emits · Pack reload completion is published as an event.
- Pack Post Load → World Creator: refreshes world · Downstream consumers may recreate or update world state.
- Pack Post Load → Pre Send Event: prepares transfer · Reload completion can lead into player migration flows.
- Pre Send Event → Sync Positions: aligns players · Player transfer workflows preserve comparative positioning.
- Pre Send Event → Player Logger: tracks players · Player movement and reconnects are logged.
- Module Manager → Biome Fix: activates · Feature toggles enable biome-registry repair behavior.
- Module Manager → Sync Positions: activates · Feature toggles enable multi-client alignment.
- Module Manager → Cycle Target: activates · Feature toggles enable reference-player cycling.
- Module Manager → Remove Dead: activates · Feature toggles enable stale-instance cleanup.
- Module Manager → MOTD: activates · Feature toggles can include server presentation behavior.
- Command Manager → ICommand: implements · Commands are registered through a shared interface contract.
- Command Manager → Reload: registers · Manual reload command is exposed to operators.
- Command Manager → Locate: registers · Biome lookup command is exposed to operators.
- Command Manager → Teleport: registers · Teleport command is exposed to operators.
- Command Manager → Reregister Biomes: registers · Biome registry refresh command is exposed to operators.
- Reload → Update Pack: calls · Manual reload invokes the same pack update pipeline.
- Reregister Biomes → Biome Fix: uses · Command path re-registers biome state during reloads.