ConfigManager

class ConfigManager(plugin: CorePlugin)

Comprehensive configuration management system for the McMMO Core plugin.

This class serves as the central hub for all configuration operations within the McMMO plugin ecosystem. It provides a type-safe, organized approach to managing plugin settings, database configuration, debugging options, and gameplay features.

Key Responsibilities:

  • Loading and parsing configuration from YAML files

  • Providing type-safe access to configuration values

  • Maintaining default values for all configuration options

  • Supporting configuration validation and error handling

  • Enabling runtime configuration updates and persistence

  • Organizing configuration into logical categories (database, debug, settings)

Configuration Categories:

  1. Database Configuration:

    • MySQL connection parameters (host, port, database name)

    • Authentication credentials (username, password)

    • Connection security options (SSL enablement)

    • Performance tuning (connection pool sizing)

  2. Debug Configuration:

    • Debug mode enablement for development and troubleshooting

    • Configurable logging levels for different environments

    • Development-specific features and verbose output

  3. Gameplay Settings:

    • Welcome message system configuration

    • Automated save intervals for data persistence

    • Player experience and interaction customization

Design Patterns:

  • Singleton-like access through the plugin instance

  • Immutable public access with private setters for data integrity

  • Lazy loading with explicit configuration loading calls

  • Default value fallbacks for missing or invalid configuration entries

Thread Safety: This class is designed to be thread-safe for reading configuration values after initialization. Configuration loading and saving operations should be performed from the main server thread to avoid concurrency issues with Bukkit's configuration system.

Error Handling: The ConfigManager provides robust error handling for common configuration issues:

  • Missing configuration files (creates defaults)

  • Invalid or corrupted YAML syntax (falls back to defaults)

  • Missing configuration keys (uses predefined defaults)

  • Type mismatches in configuration values (safe casting with defaults)

Performance Considerations:

  • Configuration values are cached in memory after loading

  • No file I/O occurs during normal configuration value access

  • Bulk configuration operations are optimized for minimal overhead

  • Configuration reloading is supported without plugin restart

Since

1.0.0

Author

McMMO Core Team

Parameters

plugin

The CorePlugin instance that owns this ConfigManager

See also

FileConfiguration

for the underlying Bukkit configuration system

for the plugin instance that uses this configuration

Constructors

Link copied to clipboard
constructor(plugin: CorePlugin)

Properties

Link copied to clipboard

The interval in minutes between automatic data saves.

Link copied to clipboard

The size of the HikariCP database connection pool.

Link copied to clipboard

The hostname or IP address of the MySQL database server.

Link copied to clipboard

The name of the MySQL database schema to use for McMMO data storage.

Link copied to clipboard

The password for authenticating with the MySQL database server.

Link copied to clipboard
var dbPort: Int

The port number for the MySQL database server connection.

Link copied to clipboard

The username for authenticating with the MySQL database server.

Link copied to clipboard

Flag indicating whether to use SSL encryption for database connections.

Link copied to clipboard

Flag indicating whether debug mode is enabled for the plugin.

Link copied to clipboard

The logging level to use when debug mode is enabled.

Link copied to clipboard

Flag indicating whether the welcome message system is enabled.

Link copied to clipboard

The welcome message template displayed to players when they join the server.

Functions

Link copied to clipboard

Loads the plugin configuration from the config.yml file and initializes all configuration properties.

Link copied to clipboard

Saves the current configuration values to the config.yml file.