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

# Configuration et données

Cette page explique où un plugin range ses fichiers, comment lire sa configuration et comment écrire ses propres données sans les abîmer. Elle sert à celles et ceux qui écrivent un plugin.

## Le dossier de données

Chaque plugin a un dossier, `plugins/<name>/`, renvoyé par `getDataFolder()` sous forme de `java.nio.file.Path`. Le serveur le crée au chargement du plugin. Garde tout ce que le plugin écrit à l'intérieur.

Il n'y a pas d'API de base de données. Un plugin qui a besoin de stockage écrit ses propres fichiers dans son dossier de données.

## `config.yml`

Si le jar contient un `config.yml` à sa racine et que le dossier de données n'en a pas, le serveur l'y copie au premier chargement. `getConfig()` lit `plugins/<name>/config.yml`. Un fichier absent ou vide donne une configuration vide. Un fichier qui n'est pas un mapping est une erreur.

```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.");
```

Les chemins utilisent des points pour parcourir les maps imbriquées.

| Méthode                 | Renvoie                               |
| ----------------------- | ------------------------------------- |
| `contains(path)`        | Si une valeur existe.                 |
| `keys()`                | Les clés de premier niveau.           |
| `get(path)`             | La valeur brute, ou `null`.           |
| `getString(path, def)`  | Une chaîne.                           |
| `getInt(path, def)`     | Un entier.                            |
| `getDouble(path, def)`  | Un double.                            |
| `getBoolean(path, def)` | Un booléen.                           |
| `getStringList(path)`   | Une liste de chaînes.                 |
| `set(path, value)`      | Fixe une valeur en mémoire.           |
| `save()`                | Écrit le fichier. Lève `IOException`. |

Donne toujours une valeur par défaut : l'administrateur peut supprimer une clé.

`save()` réécrit tout le fichier, donc les commentaires de l'original sont perdus. Garde les réglages que les gens éditent à la main dans `config.yml` et n'appelle jamais `save()` dessus. Mets les données que ton plugin génère dans un autre fichier.

## Tes propres fichiers

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

Lis et écris des fichiers dans `onEnable` et `onDisable`, ou sur un thread worker via `scheduler().runAsync`. Jamais dans un handler d'événement. Quand tu écris un fichier, écris dans un fichier temporaire puis renomme-le : un crash laisse alors l'ancien fichier ou le nouveau.


---

# 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/fr/plugins/configuration-et-donnees.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.
