> For the complete documentation index, see [llms.txt](https://docs.aethercube.fr/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.aethercube.fr/developers/building-from-source/server.md). Agents can also search and read this documentation through its [MCP server](https://docs.aethercube.fr/~gitbook/mcp).

# Server

How to build the game server and the plugin API from source. It is a Gradle multi-module project in `game-server/`, in Java 21 and Netty 4.2. The task `./gradlew :server-api:javadoc` also builds the API reference into `server-api/build/docs/javadoc/`.

## Requirements

* JDK 21. Gradle provisions one if it is missing.
* Nothing else. The Gradle wrapper downloads Gradle 9.9.2 and checks it against a pinned hash.

## Build

```sh
cd game-server
./gradlew check                          # formatting, Error Prone and every test
./gradlew :server-launcher:installDist   # the runnable distribution
./gradlew spotlessApply                  # format the code
```

On Windows use `gradlew.bat`.

The distribution is written to `server-launcher/build/install/aethercube-server/`. To run it, see [Requirements and installation](https://docs.aethercube.fr/developers/running-a-server/requirements-and-installation.md) and [First start](https://docs.aethercube.fr/developers/running-a-server/first-start.md).

## Modules

| Module              | Content                                                                                                         |
| ------------------- | --------------------------------------------------------------------------------------------------------------- |
| `server-protocol`   | Java bindings generated from `protocol/proto`.                                                                  |
| `server-api`        | The plugin API. The only module plugins may depend on.                                                          |
| `server-world`      | Chunks, the material registry, generation and persistence.                                                      |
| `server-physics`    | The deterministic player step and collisions.                                                                   |
| `server-entity`     | Entities, their lifecycle and spatial index.                                                                    |
| `server-inventory`  | Items, inventories and equipment.                                                                               |
| `server-combat`     | Statistics, the damage formula and combatants.                                                                  |
| `server-command`    | The command dispatcher and the permission service.                                                              |
| `server-plugin`     | The plugin loader, class loaders and scheduler.                                                                 |
| `server-metrics`    | The Prometheus registry and the `/metrics` endpoint.                                                            |
| `server-core`       | The event bus and the tick engine.                                                                              |
| `server-network`    | Netty, TLS 1.3, the frame codec and the connection state machine.                                               |
| `server-auth`       | Online and offline authentication, and the backend client.                                                      |
| `server-launcher`   | Configuration, player management, the native commands and the `main` of the server.                             |
| `examples:skyglass` | The example plugin. See [Example: Skyglass](https://docs.aethercube.fr/developers/plugins/example-skyglass.md). |

`build-logic/` holds the `aethercube.java-conventions` plugin. It applies the Java 21 release, Error Prone with warnings as errors, and Spotless with the Palantir Java format. Every module uses it.

## Writing a plugin in this repository

Add a module like `examples/skyglass`: apply `aethercube.java-conventions`, depend on `:server-api` with `compileOnly`, and include the module in `settings.gradle.kts`. See [Getting started](https://docs.aethercube.fr/developers/plugins/getting-started.md).

## Test vectors

Some server tests write files that the client reads. To rewrite them after an intended change:

```sh
AETHERCUBE_WRITE_VECTORS=1 ./gradlew :server-network:test :server-world:test :server-physics:test
```

Commit the changed files in `protocol/vectors/` together with the change, and run the client tests.

## Rules worth knowing

* Gameplay state is touched on the simulation thread only. Disk work goes to the storage thread and generation to workers.
* Tickets, server secrets and packet payloads are never logged.
* When you change a packet, a config key or a plugin API method, the matching documentation page changes with it.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.aethercube.fr/developers/building-from-source/server.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
