Storage and Persistence - AshleyThew/Bank GitHub Wiki
Storage and Persistence
Overview
Bank supports SQLITE, MYSQL, and MONGODB save types selected by config.
Storage is made of multiple subsystems: account payloads, lock state, transaction history, and mapping tables.
How It Works
Startup selects backend from Bank.Save.Type and initializes a BankDatabase wrapper.
If non-SQLite connection fails, plugin falls back to SQLite.
SQL backends register listeners for:
- UUID mapping
- info type mapping and info payload storage
- player lock state
- hiscores
- transaction tables
- cheque data
Mongo backend requires Mongo driver availability (via mongodb-loader plugin).
Storage subsystems
- Account payload subsystem: player info JSON by type.
- UUID mapping subsystem: player UUID and name mapping.
- Lock subsystem: boolean lock or time-based lock model.
- Transaction subsystem: money and exp history tables.
- Ranking subsystem: hiscore/baltop data.
Configuration
Files:
config.yml(Bank.Save.Type, lock and autosave settings)mysql.ymlmongo.ymlconvert.yml
Reference files:
MySQL backend baseline:
Bank:
Save:
Type: MYSQL
Lock:
Time: true
Auto:
Enabled: true
Timer: 600
Admin sequence when changing backend:
- Backup existing data.
- Configure target backend file.
- Set save/conversion keys.
- Restart and validate logs before opening server.
Commands
/bank admin save/bank admin reload/bank admin fix usernames
Permissions
Storage operations are primarily admin-command gated.
Data and Storage
SQL schema highlights:
bank_info_type: maps info classes to IDsbank_player_info: JSON payload per UUID and info typebank_uuids: UUID/name mappingsbank_player_lockandbank_player_time_lock- money/exp transaction tables (auto-created)
Locking:
- Standard lock table uses boolean lock state.
- Time-lock mode uses timestamp unlock windows.
Retention notes:
- Transaction growth depends on configured max history and cleanup behavior.
- Lock mode should be consistent across all servers sharing one backend.
Examples
- Single server:
SQLITEdefault, localdatabase.db. - Network:
MYSQLwith exactly one main server for offline interest managers.
Troubleshooting
- MySQL fails then SQLite appears active: check credentials in
mysql.ymland startup logs. - Mongo mode fails: install
mongodb-loaderand validatemongo.yml. - Repeated lock conflicts across servers: verify common lock mode and synchronized save settings.