Add `Events` and `EventBus` for mod-driven event handling with support for main-thread and mod-thread execution. Introduce `MainThread` and `AsyncExecutor` for modular threading and background task management. Add `ForgeSettings` to manage global mod configuration through `forge.toml`. Include tests for events, threading, and configuration parsing to improve robustness and maintainability.
93 lines
6.8 KiB
Markdown
93 lines
6.8 KiB
Markdown
# ZomboidForge
|
||
|
||
An official‑client‑compatible, container‑ready Project Zomboid dedicated server with
|
||
first‑class support for custom Java mods and drop‑in server builds.
|
||
|
||
## Building
|
||
|
||
The container image downloads the vanilla dedicated server (Steam app 380870) with an
|
||
anonymous steamcmd login while it builds, and patches it. No game files are part of this
|
||
repository. The build fails when the downloaded server is not the Project Zomboid
|
||
version in `gradle.properties` (`pz.version`).
|
||
|
||
```sh
|
||
podman build --platform linux/amd64 -t zomboidforge . # or: docker build ...
|
||
```
|
||
|
||
| Build argument | Default | |
|
||
|--------------------|--------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------|
|
||
| `PZ_BRANCH` | `public` | Steam branch: `public`, `unstable`, or a version branch such as `42.19` |
|
||
| `PZ_VERSION` | `pz.version` | Expected Project Zomboid version |
|
||
| `STEAMCLIENT` | `bundled` | `steamcmd` replaces the server's `steamclient.so` files with steamcmd's newer copies (workaround for failing Workshop downloads) |
|
||
| `FORGE_VERSION` | `0.0.0-prerelease` | ZomboidForge version (jar manifest, image label). The build stage has no `git`, so the version is never read from a tag there; `ci/release.sh` passes it |
|
||
| `DISABLED_PATCHES` | | Comma-separated simple class names of build-time patches to skip (debug builds only), e.g. `IsoZombieVehiclePerformancePatch` |
|
||
|
||
Published images are tagged `<forge>-pz<pz>-build<steam buildid>` (immutable),
|
||
`<forge>-pz<pz>`, and `latest`.
|
||
|
||
## Running
|
||
|
||
```sh
|
||
podman run -d --name zomboidforge \
|
||
-e ADMIN_PASSWORD=... -e RCON_PASSWORD=... \
|
||
-p 16261:16261/udp -p 16262:16262/udp -p 127.0.0.1:27015:27015/tcp \
|
||
-v zomboid-data:/data zomboidforge
|
||
```
|
||
|
||
Unset variables keep the value in the server `.ini` (or the game default).
|
||
|
||
| Variable | Default | |
|
||
|-------------------|----------------|-----------------------------------------------------------------------------------------------------|
|
||
| `SERVER_NAME` | `zomboidforge` | Server config name (`/data/Server/<name>.ini`) |
|
||
| `SERVER_PASSWORD` | | Password clients need to join (`.ini` `Password`) |
|
||
| `PUBLIC` | | `true`/`false`: listed in the in-game server browser |
|
||
| `PUBLIC_NAME` | | Name in the server browser |
|
||
| `PORT` | `16261` | Game port (`-port`) |
|
||
| `UDP_PORT` | `16262` | Direct connection port (`-udpport`) |
|
||
| `ADMIN_USERNAME` | `admin` | First start only |
|
||
| `ADMIN_PASSWORD` | | Required on the first start, ignored afterwards |
|
||
| `SERVER_PRESET` | | Sandbox preset for a new server: `Apocalypse`, `Extinction`, `Outbreak`, `Rising`, `SixMonthsLater` |
|
||
| `MODS` | | Mod IDs, Build 42 format: `\ModA;\ModB` |
|
||
| `WORKSHOP_ITEMS` | | Workshop item IDs: `123;456` |
|
||
| `RCON_PASSWORD` | | Written into the `.ini` on every start; RCON is disabled without it |
|
||
| `JVM_MIN_HEAP` | | `-Xms` |
|
||
| `JVM_MAX_HEAP` | `8g` | `-Xmx` |
|
||
| `STEAM` | `1` | `0` runs the server without Steam |
|
||
| `SOFT_RESET` | | `true` starts once in soft reset mode (`-Dsoftreset`); unset it afterwards |
|
||
|
||
Notes:
|
||
|
||
- **Ports:** host and container ports must be the same. The server announces its own
|
||
port, so `-p 17000:16261/udp` is unreachable; set `PORT=17000` and publish
|
||
`17000:17000/udp` instead.
|
||
- **Data:** `/data` holds the server config, saves, database, logs, and downloaded Workshop
|
||
items (`/data/steamapps`). The server runs as UID 1000. A bind-mounted host directory
|
||
must be writable by UID 1000 (`chown 1000:1000 <dir>`); with rootless Podman, use
|
||
`--userns=keep-id:uid=1000,gid=1000` to map it to your own user.
|
||
- **Java mods:** mount a directory at `/forge` (e.g. `-v ./forge:/forge`) with one folder
|
||
per mod: `mods/<id>/<id>.jar`, optional `mods/<id>/lib/*.jar`, and the mod's settings in
|
||
`mods/<id>/config.toml`. A missing `config.toml` is created from the mod's defaults when
|
||
the folder is writable by UID 1000. `[forge]` `enabled = false` in it switches the mod off.
|
||
A mod that cannot be loaded (missing dependency, wrong game version, game classes that do
|
||
not exist in the running version, failing `onLoad`) stops the server with exit code 1 and
|
||
lists every problem in the log. Optional `/forge/forge.toml`: `[main_thread] budget_ms`
|
||
(time per tick for mods' main-thread tasks, default 2) and `[shutdown] timeout_s` (time
|
||
mod threads get to finish when the server stops, default 10).
|
||
- **Stopping:** `SIGTERM` triggers the game's own save-and-quit. Allow enough time for large
|
||
worlds (`podman stop -t 120`, `stop_grace_period` in compose).
|
||
|
||
For local testing there is `compose.yaml` (`podman compose up --build`, settings from `.env`).
|
||
|
||
## Development
|
||
|
||
Requires JDK 25 (the game's runtime). The Gradle build compiles against a local vanilla
|
||
server jar, `lib/server/java/projectzomboid.jar` by default (override with `-Ppz.jar=...`).
|
||
|
||
```sh
|
||
./gradlew build # compile + tests
|
||
./gradlew :patcher:patchServerJar # -> patcher/build/server/projectzomboid.jar
|
||
```
|
||
|
||
Game-specific code lives in `compat/b<major>/`; `api` and `core` are version-independent.
|
||
`pz.version` in `gradle.properties` selects the targeted version.
|