> 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/plugins/getting-started.md). Agents can also search and read this documentation through its [MCP server](https://docs.aethercube.fr/~gitbook/mcp).

# Getting started

This page takes you from an empty folder to a plugin that answers a command. Start here if you want to extend the server in Java.

A plugin is a Java 21 jar. The server loads it from the `plugins/` folder and runs it inside the server process, with the same trust as the server itself. There is no sandbox, so install only plugins you trust.

The pages of this section explain the concepts. The complete API reference, every class and method, is the javadoc of `server-api`. Generate it with `./gradlew :server-api:javadoc` from `game-server/`. It ends up in `game-server/server-api/build/docs/javadoc/`.

## What you need

* JDK 21.
* The plugin API: the `server-api` module of the repository.
* A `plugin.yml` at the root of the jar.

There is no published SDK artifact yet, so for now you build against the API in one of two ways.

### Option 1: a subproject of `game-server`

Add a folder next to `examples/skyglass` and include it in `settings.gradle.kts`. Copy the build file of the example:

```kotlin
plugins {
    id("aethercube.java-conventions")
}

dependencies {
    compileOnly(project(":server-api"))
}
```

`compileOnly` is the rule. The server provides the API at run time. The convention plugin applies Error Prone with warnings as errors and the Spotless formatter, so the code is checked like the server's.

Build the jar and copy it to the server:

```sh
./gradlew :examples:skyglass:jar
cp examples/skyglass/build/libs/*.jar /path/to/my-server/plugins/
```

### Option 2: your own project

Build the API jar once:

```sh
cd game-server
./gradlew :server-api:jar
```

The jar is `server-api/build/libs/server-api-<version>.jar`, where the version comes from `gradle.properties`. The API also uses SLF4J (`org.slf4j.Logger`). Add both as `compileOnly` dependencies:

```kotlin
dependencies {
    compileOnly(files("libs/server-api-0.1.0-alpha.1.jar"))
    compileOnly("org.slf4j:slf4j-api:2.0.20")
}
```

Package the compiled classes, `plugin.yml` and any resources into one jar with a standard `jar` task.

## A first plugin

`src/main/resources/plugin.yml`:

```yaml
name: Hello
version: 1.0.0
main: com.example.hello.Hello
api-version: "1.0"
commands:
  hello:
    description: Greets you
    usage: /hello
permissions: {}
```

`src/main/java/com/example/hello/Hello.java`:

```java
package com.example.hello;

import com.velyorix.game.api.command.CommandContext;
import com.velyorix.game.api.command.CommandResult;
import com.velyorix.game.api.plugin.JavaPlugin;

public final class Hello extends JavaPlugin {

    @Override
    public void onEnable() {
        registerCommand("hello", this::hello);
        getLogger().info("Hello is enabled on server {}", getServer().version());
    }

    private CommandResult hello(CommandContext context) {
        return CommandResult.ok("Hello, " + context.sender().name() + ".");
    }
}
```

Copy the jar to `plugins/`, start the server and run `/plugins`. The plugin shows as `enabled`. Run `/hello`.

## Rules to know early

* **A command must be declared in `plugin.yml`.** `registerCommand` looks it up there and throws for an undeclared name. That way `/help` and the permission system know about every command before your code runs.
* **Your classes see only the API.** A plugin class loader exposes `java.*`, `javax.*`, `jdk.*`, `org.slf4j.*` and `com.velyorix.game.api.*`. Server internals are not visible, so I can change them without breaking you. A jar that redefines these packages is marked `INCOMPATIBLE`.
* **Gameplay runs on one thread.** Events, commands and scheduled tasks run on the simulation thread. See [Lifecycle and threads](https://docs.aethercube.fr/developers/plugins/lifecycle-and-threads.md).
* **Register content early.** Items and creature types must be registered before the network starts, which means in `onEnable`. Clients are told about them once, when they join.
* **There is no hot reload.** Restart the server to change a plugin.

## Where to go next

| Topic                      | Page                                                                                                  |
| -------------------------- | ----------------------------------------------------------------------------------------------------- |
| The `plugin.yml` file      | [plugin.yml](https://docs.aethercube.fr/developers/plugins/plugin-yml.md)                             |
| Load order and states      | [Lifecycle and threads](https://docs.aethercube.fr/developers/plugins/lifecycle-and-threads.md)       |
| Config and files           | [Configuration and data](https://docs.aethercube.fr/developers/plugins/configuration-and-data.md)     |
| Commands and permissions   | [Commands and permissions](https://docs.aethercube.fr/developers/plugins/commands-and-permissions.md) |
| Reacting to the game       | [Events](https://docs.aethercube.fr/developers/plugins/events.md)                                     |
| Delayed and repeating work | [Scheduler](https://docs.aethercube.fr/developers/plugins/scheduler.md)                               |
| A complete example         | [Example: Skyglass](https://docs.aethercube.fr/developers/plugins/example-skyglass.md)                |


---

# 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/plugins/getting-started.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.
