Class ConfigurationManager

java.lang.Object
dev.crafty.core.config.ConfigurationManager

public class ConfigurationManager extends Object
Manager for handling configuration files and annotations. This class is responsible for loading configuration files, processing configuration annotations, and populating fields.
Since:
1.0.0
  • Constructor Summary

    Constructors
    Constructor
    Description
    ConfigurationManager(org.bukkit.plugin.Plugin plugin)
    Create a new configuration manager.
  • Method Summary

    Modifier and Type
    Method
    Description
    org.bukkit.configuration.file.YamlConfiguration
    loadConfig(Class<?> clazz)
    Load a configuration file for a class.
    org.bukkit.configuration.file.YamlConfiguration
    loadConfig(Class<?> clazz, org.bukkit.plugin.Plugin plugin)
    Load a configuration file for a class using a specific plugin's data folder.
    void
    populateObject(Object object, org.bukkit.plugin.Plugin plugin)
    Populate an object with values from its configuration file using a specific plugin's data folder.
    org.bukkit.configuration.file.YamlConfiguration
    reloadConfig(Class<?> clazz)
    Reload a configuration file for a class from disk.
    void
    Reload an object's configuration from disk and repopulate its fields.
    void
    reloadObject(Object object, org.bukkit.plugin.Plugin plugin)
    Reload an object's configuration from disk and repopulate its fields using a specific plugin's data folder.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • ConfigurationManager

      public ConfigurationManager(org.bukkit.plugin.Plugin plugin)
      Create a new configuration manager.
      Parameters:
      plugin - The plugin instance
  • Method Details

    • loadConfig

      public org.bukkit.configuration.file.YamlConfiguration loadConfig(Class<?> clazz)
      Load a configuration file for a class.
      Parameters:
      clazz - The class to load the configuration for
      Returns:
      The loaded configuration
      Throws:
      IllegalArgumentException - If the class is not annotated with @ConfigurationFile
    • loadConfig

      public org.bukkit.configuration.file.YamlConfiguration loadConfig(Class<?> clazz, org.bukkit.plugin.Plugin plugin)
      Load a configuration file for a class using a specific plugin's data folder.
      Parameters:
      clazz - The class to load the configuration for
      plugin - The plugin to load the configuration from
      Returns:
      The loaded configuration
      Throws:
      IllegalArgumentException - If the class is not annotated with @ConfigurationFile
    • reloadConfig

      public org.bukkit.configuration.file.YamlConfiguration reloadConfig(Class<?> clazz)
      Reload a configuration file for a class from disk.
      Parameters:
      clazz - The class to reload the configuration for
      Returns:
      The reloaded configuration
      Throws:
      IllegalArgumentException - If the class is not annotated with @ConfigurationFile
    • populateObject

      public void populateObject(Object object, org.bukkit.plugin.Plugin plugin)
      Populate an object with values from its configuration file using a specific plugin's data folder.
      Parameters:
      object - The object to populate
      plugin - The plugin to load the configuration from
      Throws:
      IllegalArgumentException - If the object's class is not annotated with @ConfigurationFile
    • reloadObject

      public void reloadObject(Object object)
      Reload an object's configuration from disk and repopulate its fields. This is useful for updating an object's fields when the configuration file has changed.
      Parameters:
      object - The object to reload
      Throws:
      IllegalArgumentException - If the object's class is not annotated with @ConfigurationFile
    • reloadObject

      public void reloadObject(Object object, org.bukkit.plugin.Plugin plugin)
      Reload an object's configuration from disk and repopulate its fields using a specific plugin's data folder. This is useful for updating an object's fields when the configuration file has changed.
      Parameters:
      object - The object to reload
      plugin - The plugin to reload the configuration from
      Throws:
      IllegalArgumentException - If the object's class is not annotated with @ConfigurationFile