saveConfig

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

This method performs a complete configuration save operation, writing all current configuration values from memory back to the configuration file. This is useful for programmatic configuration changes or configuration management commands.

Save Operation Process:

  1. Database Configuration Saving:

    • Writes all database connection parameters to their respective keys

    • Includes host, port, database name, credentials, and SSL settings

    • Preserves connection pool size and other performance settings

  2. Debug Configuration Saving:

    • Saves debug mode enablement flag

    • Preserves log level settings for consistent debugging

  3. Gameplay Settings Saving:

    • Writes welcome message system configuration

    • Preserves autosave interval and other gameplay settings

  4. File Persistence:

    • Calls plugin.saveConfig() to write changes to disk

    • Ensures atomic file operations to prevent corruption

    • Maintains YAML formatting and structure

Configuration Sections Written:

Database Section:

  • database.host: MySQL server hostname or IP address

  • database.port: MySQL server port number

  • database.name: Database schema name

  • database.username: Database authentication username

  • database.password: Database authentication password

  • database.useSSL: SSL encryption enablement flag

  • database.connectionPoolSize: HikariCP connection pool size

Debug Section:

  • debug.enabled: Debug mode enablement flag

  • debug.logLevel: Logging verbosity level

Settings Section:

  • settings.enableWelcomeMessage: Welcome message system enablement

  • settings.welcomeMessage: Welcome message template

  • settings.autosave_interval_minutes: Automatic save interval

Use Cases:

  • Administrative commands that modify configuration

  • Plugin setup wizards or configuration GUIs

  • Programmatic configuration management

  • Migration or upgrade procedures

Thread Safety: This method should be called from the main server thread to ensure thread safety with Bukkit's configuration system and file operations.

Error Handling:

  • File I/O errors are handled by Bukkit's configuration system

  • Malformed configuration values are written as provided

  • Backup of existing configuration is handled by Bukkit

Performance Considerations:

  • Configuration saving involves file I/O and should be used judiciously

  • Frequent configuration saves may impact server performance

  • Configuration changes take effect immediately after loading

Data Integrity:

  • Bukkit's configuration system provides atomic file operations

  • Original configuration file is preserved during save operations

  • YAML structure and formatting are maintained

Since

1.0.0

See also

for the corresponding configuration loading method

FileConfiguration.set

for individual value setting

Plugin.saveConfig

for the underlying file save operation