Database & Redis
Setting up storage backends and multi-server Redis synchronization.
Database Backends
mineTeams supports four storage backends. Teams and player profiles use the same engine.
database:
database-type: H2
hostname: "localhost"
base: "mineTeams"
port: 3306
username: "root"
password: "securepass"
| Type | Best for | Notes |
|---|---|---|
H2 | Single server, testing | Default embedded database |
MYSQL | Production multi-server | Shared SQL storage |
MONGODB | Document-oriented production | Host/port/user/password auth |
FLAT | Simple file storage | YAML files on disk |
H2 (Default)
No external service required. Data is stored under the plugin data folder.
database:
database-type: H2
Warning: Do not use H2 for multi-server networks. Each server would keep a separate database. Use MySQL or MongoDB with Redis.
MySQL
database:
database-type: MYSQL
hostname: "localhost"
base: "mineTeams"
port: 3306
username: "root"
password: "securepass"
Uses HikariCP connection pooling.
MongoDB
database:
database-type: MONGODB
hostname: "localhost"
base: "mineTeams"
port: 27017
username: "root"
password: "securepass"
Connects with username/password credentials against the configured database name.
FLAT (YAML)
database:
database-type: FLAT
Stores entities as YAML files. Suitable for small communities or debugging; not recommended for large networks.
Stored Data
| Entity | Contents |
|---|---|
| Team | Tag, name, leader, members, deputies, slots, base, friendly fire, created/expires timestamps |
| Profile | UUID, username, statistics (kills, deaths, assists, ranking), team-chat toggle, abuse-related state |
Access always goes through TeamService / ProfileService (cache). Direct DAO use is internal only.
Redis Synchronization
Optional multi-server sync for teams, profiles, and team chat.
redis:
enable: true
host: "127.0.0.1:6379"
password: "strongPass"
server-id: "survival-1"
| Option | Description |
|---|---|
enable | Turn Redis pub/sub on |
host | host:port of Redis |
password | Redis AUTH password |
server-id | Unique id of this Minecraft server instance |
Topics
| Topic | Message | Purpose |
|---|---|---|
| Team synchronize | TeamSynchronizeMessage | Propagate team create/update/delete |
| Profile synchronize | ProfileSynchronizeMessage | Propagate profile/ranking changes |
| Chat synchronize | ChatSynchronizeMessage | Cross-server team chat |
How It Works
- Local mutation updates the in-memory cache
- When Redis is enabled, a message is published
- Other servers apply the update to their cache without re-publishing (loop prevention)
- Handlers may run off the main thread — do not assume sync on the primary thread in custom forks
Multi-server checklist
- Shared MySQL or MongoDB for all game servers
- Shared Redis with
enable: true - Distinct
server-idper instance - Same plugin version and compatible configs across the network
Single-server vs Multi-server
| Setup | Database | Redis |
|---|---|---|
| One server | H2 / MySQL / Mongo / FLAT | Off |
| Network | MySQL or MongoDB | On |
Troubleshooting
| Issue | Check |
|---|---|
| Data not shared across servers | Shared DB + Redis enabled + unique server-id |
| Connection refused | Hostname, port, firewall, credentials |
| Stale ranking tops | Ranking calculation task running; Redis profile sync healthy |
| Teams missing after switch to MySQL | Migrate data; empty DB starts clean |