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

# Configuration and data

How a plugin reads its settings and stores its own files. You need this page as soon as your plugin has anything an administrator might want to change.

## The data folder

Each plugin has a folder, `plugins/<name>/`, returned by `getDataFolder()` as a `java.nio.file.Path`. The server creates it when the plugin loads. Keep everything the plugin writes inside it.

There is no database API. If your plugin needs storage, write your own files in its data folder.

## `config.yml`

If the jar holds a `config.yml` at its root and the data folder has none, the server copies it there on first load. `getConfig()` reads `plugins/<name>/config.yml`. A missing or empty file is an empty configuration. A file that is not a mapping is an error.

```yaml
# config.yml
loading-backdrop: true
drifter-spawn-weight: 2
messages:
  welcome: "Welcome to the isles."
```

```java
int weight = getConfig().getInt("drifter-spawn-weight", 2);
String welcome = getConfig().getString("messages.welcome", "Welcome.");
```

Paths use dots to walk nested maps.

| Method                  | Returns                                |
| ----------------------- | -------------------------------------- |
| `contains(path)`        | Whether a value exists.                |
| `keys()`                | The top-level keys.                    |
| `get(path)`             | The raw value, or `null`.              |
| `getString(path, def)`  | A string.                              |
| `getInt(path, def)`     | An integer.                            |
| `getDouble(path, def)`  | A double.                              |
| `getBoolean(path, def)` | A boolean.                             |
| `getStringList(path)`   | A list of strings.                     |
| `set(path, value)`      | Sets a value in memory.                |
| `save()`                | Writes the file. Throws `IOException`. |

Always give a default. The administrator can delete a key.

`save()` rewrites the whole file, so comments of the original are lost. Keep settings that people edit by hand in `config.yml` and never call `save()` on it. Put data your plugin generates in another file.

## Files of your own

```java
Path file = getDataFolder().resolve("scores.json");
```

Read and write files in `onEnable` and `onDisable`, or on a worker thread through `scheduler().runAsync`. Never in an event handler. When you write a file, write to a temporary file and rename it, so a crash leaves the old or the new file.


---

# 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/configuration-and-data.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.
