Package dev.crafty.core.config
Class ConfigurationManager
java.lang.Object
dev.crafty.core.config.ConfigurationManager
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
ConstructorsConstructorDescriptionConfigurationManager
(org.bukkit.plugin.Plugin plugin) Create a new configuration manager. -
Method Summary
Modifier and TypeMethodDescriptionorg.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
reloadObject
(Object object) 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.
-
Constructor Details
-
ConfigurationManager
public ConfigurationManager(org.bukkit.plugin.Plugin plugin) Create a new configuration manager.- Parameters:
plugin
- The plugin instance
-
-
Method Details
-
loadConfig
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 forplugin
- The plugin to load the configuration from- Returns:
- The loaded configuration
- Throws:
IllegalArgumentException
- If the class is not annotated with @ConfigurationFile
-
reloadConfig
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
Populate an object with values from its configuration file using a specific plugin's data folder.- Parameters:
object
- The object to populateplugin
- The plugin to load the configuration from- Throws:
IllegalArgumentException
- If the object's class is not annotated with @ConfigurationFile
-
reloadObject
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
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 reloadplugin
- The plugin to reload the configuration from- Throws:
IllegalArgumentException
- If the object's class is not annotated with @ConfigurationFile
-