Add optional MySQL support for statistics storage
Build / build (push) Successful in 1m15s

This commit is contained in:
Michael Burgess
2026-08-07 06:09:24 -04:00
parent bcb603dadf
commit 1c16f9a83b
7 changed files with 128 additions and 25 deletions
+27 -2
View File
@@ -151,6 +151,31 @@ Commands run as the console, so no Vault/economy plugin is required by BlockPart
if you reference an economy command (like `eco give`) you need that plugin installed
separately. `%player%`, `%arena%` and `%round%` are replaced before dispatch.
## Statistics storage
By default player statistics are stored in a local SQLite file (`plugins/BlockParty/blockparty.db`) —
zero setup required. To use a shared MySQL database instead (useful across a network of servers),
set `storage.type: mysql` in `config.yml`:
```yaml
storage:
type: mysql
mysql:
host: localhost
port: 3306
database: blockparty
username: blockparty
password: password
use-ssl: false
table-prefix: "bp_"
```
The MySQL JDBC driver (`mysql-connector-j`) is bundled in the plugin jar, so no extra
download is required. The stats table is created automatically on startup if it doesn't
exist. All queries run asynchronously off the main thread regardless of storage type.
Changing `storage.type` requires a server restart (it's read once at startup, not on
`/blockparty reload`).
## PlaceholderAPI support
If PlaceholderAPI is installed, BlockParty registers a `%blockparty_...%` expansion
@@ -169,7 +194,7 @@ automatically (soft-dependency — startup never fails if PAPI is absent):
./gradlew clean build
```
The shaded plugin jar (with `sqlite-jdbc` bundled and relocated) is produced at
The shaded plugin jar (with `sqlite-jdbc` and `mysql-connector-j` bundled) is produced at
`build/libs/BlockParty-<version>.jar`.
Run unit tests only:
@@ -208,6 +233,6 @@ elimination/winner determination, arena config validation, and player-count/join
- `listener/` — connection/quit handling and gameplay restrictions.
- `scoreboard/` — interval-based sidebar scoreboard.
- `reward/` — console-command reward dispatch.
- `persistence/` — async SQLite-backed stats (`StatsDatabase`, `StatsManager`).
- `persistence/` — async stats storage over SQLite or MySQL (`StatsDatabase`, `StatsManager`).
- `placeholder/` — optional PlaceholderAPI expansion, loaded only when PAPI is present.
- `util/` — sound/location helpers.