$ show Lixeer/ValleyServer
ValleyServer is a dual-mainline project that turns Stardew Valley into a persistent, unattended multiplayer server. The 2.x branch (recommended, stable) runs on a real Stardew Valley + SMAPI client, using a set of custom mods (ALOS, ServerCMD, ChatCommand, CommandWebUI, ChangeServerPort) to automate the host farmerβauto-sleeping, skipping cutscenes, handling festivals, and providing a web-based console and Docker deployment. The 3.x branch (experimental) is a standalone headless server that loads decompiled game assemblies via reflection and mocking, implements the Lidgren-based multiplayer protocol, and manages farmhand connections, warps, saving, and day transitions without any graphical client. The 3.x code is architecturally ambitiousβusing uninitialized objects to bypass XNA dependencies, a custom content manager that returns dummy textures/fonts, and a dedicated overnight coroutine threadβbut remains incomplete (missing farming, NPCs, seasons) and is tightly coupled to a specific decompiled game version. The 2.x mods are well-documented and production-tested; the 3.x server is a technical proof-of-concept with hardcoded paths and significant fragility. The repository provides CI/CD for building both branches, issue templates, and a community Docker image.
The LLM identified 4 files worth highlighting for reuse:
Robust, layered configuration loader for the headless server. Reads from config.json, applies environment variable and command-line overrides, normalizes null sections, validates ranges, and logs the effective configuration. The pattern of fail-safe defaults, clear validation messages, and multi-source override precedence is cleanly separated and could be extracted as a reusable config utility for any .NET CLI application.
Simple but well-crafted command registry and tokenizer. ServerCommand encapsulates name, aliases, usage, description, and handler. The registry prevents duplicate registration and supports case-insensitive lookup by name or alias. The static Tokenize() method handles quotes and byte-order marks. This lightweight, testable pattern could be lifted into any server or CLI project that needs a composable command set.
Pure helpers for inspecting and cloning Stardew Valley's multiplayer protocol messages. Provides static methods to describe outgoing/incoming messages (with subtype and name decoding for NewDaySync and NetReady), and a Clone() method that performs a deep copy of an IncomingMessage. This separation of protocol logic from the monolithic Program.cs makes it independently testable and potentially reusable for protocol analysis or proxy tools.
Background thread that reads console input and queues lines for the main loop to drain. Handles non-interactive input (piped or detached) gracefully by disabling itself. The Drain() method is called from the main loop, ensuring command handlers always run in a consistent game/network state. This is a clean demonstration of decoupling input capture from execution, transferable to any server that needs asynchronous console processing.