Skip to content

Storage and Persistence

AshleyThew edited this page Jul 5, 2026 · 1 revision

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.yml
  • mongo.yml
  • convert.yml

Reference files:

MySQL backend baseline:

Bank:
  Save:
    Type: MYSQL
    Lock:
      Time: true
    Auto:
      Enabled: true
      Timer: 600

Admin sequence when changing backend:

  1. Backup existing data.
  2. Configure target backend file.
  3. Set save/conversion keys.
  4. 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 IDs
  • bank_player_info: JSON payload per UUID and info type
  • bank_uuids: UUID/name mappings
  • bank_player_lock and bank_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: SQLITE default, local database.db.
  • Network: MYSQL with exactly one main server for offline interest managers.

Troubleshooting

  • MySQL fails then SQLite appears active: check credentials in mysql.yml and startup logs.
  • Mongo mode fails: install mongodb-loader and validate mongo.yml.
  • Repeated lock conflicts across servers: verify common lock mode and synchronized save settings.

Related Pages

Clone this wiki locally