DatabaseManager

Comprehensive database management system for the McMMO Core plugin.

This class serves as the central hub for all database operations within the McMMO ecosystem. It manages connection pooling using HikariCP, handles database schema creation and maintenance, and provides reliable database connections to all other components of the plugin system.

Key Responsibilities:

  • Database connection pool management using HikariCP for optimal performance

  • Automatic database schema creation and validation for all core tables

  • Connection health monitoring and automatic recovery mechanisms

  • Thread-safe database access for multi-threaded plugin operations

  • Configuration-driven database setup supporting MySQL with SSL options

  • Comprehensive error handling and logging for database operations

The DatabaseManager follows a singleton-like pattern within the plugin lifecycle, being initialized once during plugin startup and maintained throughout the server's runtime. It supports both online and offline player data management scenarios.

Database Schema Coverage:

  • Player core data (levels, currency, flags, preferences)

  • Player inventory persistence across sessions

  • Skills and progression system data

  • Quest system state and completion tracking

  • Moderation tools (mutes, ignores)

  • Companion and mount system data

  • Dungeon and raid lockout management

  • Economy system (auctions, mail)

  • Guild system with hierarchical permissions

Thread Safety: This class is designed to be thread-safe through the use of HikariCP's connection pooling, which handles concurrent access to database connections safely across multiple plugin threads and async operations.

Performance Considerations:

  • Uses connection pooling to minimize connection overhead

  • Implements prepared statement caching for frequently used queries

  • Configures MySQL-specific optimizations for batch operations

  • Provides configurable pool sizing based on server load requirements

Since

1.0.0

Author

McMMO Core Team

Parameters

plugin

The CorePlugin instance that owns this DatabaseManager

See also

HikariDataSource

for connection pooling implementation

for database configuration management

Constructors

Link copied to clipboard
constructor(plugin: CorePlugin)

Properties

Link copied to clipboard

Property providing access to database connections from the HikariCP connection pool.

Link copied to clipboard

Property indicating whether the DatabaseManager is currently initialized and ready for use.

Functions

Link copied to clipboard

Initializes the DatabaseManager and establishes the database connection infrastructure.

Link copied to clipboard
fun shutdown()

Gracefully shuts down the DatabaseManager and closes all database connections.