# Data Storage

## 🧭 Overview

The plugin supports two main storage methods for saving player and game data:

* **Local (JSON Files)** — Easy to access and modify directly.
* **MySQL Database** — Recommended for larger servers or multi-instance setups.

All player data, statistics, and settings are stored in structured JSON files by default, ensuring easy manual editing when needed.

{% hint style="info" %}

* Switching between **local** and **MySQL** storage can be done at any time — just restart the server after changing settings.
* Player data is saved in **JSON format**, making it easy to manually view or edit stats.
* For **multi-server environments** (e.g., Bungee or Velocity networks), MySQL is **strongly recommended**.
  {% endhint %}

***

## 📁 File Structure

All data is located in the `/ArenaLegends/data/` directory.

| Path                 | Description                                         |
| -------------------- | --------------------------------------------------- |
| `/data/settings.yml` | Contains various local plugin settings.             |
| `/data/metrics.yml`  | Used for tracking plugin metrics and analytics.     |
| `/data/players/`     | Stores individual player data files in JSON format. |

Example structure:

```
/ArenaLegends/
 └── data/
     ├── settings.yml
     ├── metrics.yml
     └── players/
         ├── Notch.json
         ├── Steve.json
         └── Alex.json
```

***

## 🗄️ MySQL Integration

You can switch from local file storage to **MySQL** for centralized and scalable data management.

#### How to Enable MySQL

1. Open your main configuration file:

   ```
   /ArenaLegends/config.yml
   ```
2. Locate the `mysql-settings` section.
3. Set `enabled` to `true`.
4. Fill in your database credentials (host, port, database, username, password).

### ⚙️ Configuration

```yaml
mysql:
  connection:
    # Turn on/off the MySQL connection.
    enabled: false
    # The address to connect to the database.
    url: "jdbc:mysql://{HOST}:{PORT}/{NAME}"
    # The highest number of connections allowed at once.
    maximum-pool-size: 10
    # The lowest number of spare connections to keep ready.
    minimum-idle: 5
    # How long a connection can exist (in milliseconds).
    max-lifetime: 1800000
    # How long an unused connection stays open (in milliseconds).
    idle-timeout: 600000
    # How long to wait for a connection before giving up (in milliseconds).
    connection-timeout: 30000
    # Time to wait before warning about a stuck connection (in milliseconds).
    leak-detection-threshold: 60000
    # Automatically save database changes.
    auto-commit: true
  credentials:
    # The computer address where MySQL is running.
    host: "value"
    # The connection port number for MySQL.
    port: "3306"
    # The name of your database.
    name: "value"
    # Your MySQL username.
    user: "value"
    # Your MySQL password.
    pass: "value"
```
