Class ConfigService
java.lang.Object
com.zetaplugins.zetacore.services.config.ConfigService
Service for managing plugin configuration files with caching support.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidClear the configuration cache.getConfig(PluginConfigFile config) Get a configuration file based on the provided PluginConfig enum.getConfig(PluginConfigFile config, boolean useCache) Get a configuration file based on the provided PluginConfig enum.<T> TGet a configuration mapped to the specified configuration class.<T> TGet a configuration mapped to the specified configuration class.Get a configuration file based on the provided file name.Get a configuration file based on the provided file name.voidsaveConfig(PluginConfigFile config, FileConfiguration fileConfig) Save a configuration file based on the provided PluginConfig enum.voidsaveConfig(String fileName, FileConfiguration fileConfig) Save a configuration file based on the provided file name.
-
Constructor Details
-
ConfigService
Construct a new ConfigService.- Parameters:
plugin- The JavaPlugin instance.
-
-
Method Details
-
getConfig
Get a configuration file based on the provided PluginConfig enum.- Parameters:
config- The PluginConfig enum representing the desired configuration file.- Returns:
- The FileConfiguration object for the specified configuration file.
-
getConfig
Get a configuration file based on the provided PluginConfig enum.- Parameters:
config- The PluginConfig enum representing the desired configuration file.useCache- Whether to use the cached version if available.- Returns:
- The FileConfiguration object for the specified configuration file.
-
getConfig
Get a configuration file based on the provided file name.- Parameters:
fileName- The name of the configuration file (without the .yml extension).- Returns:
- The FileConfiguration object for the specified configuration file.
-
getConfig
Get a configuration file based on the provided file name.- Parameters:
fileName- The name of the configuration file (without the .yml extension).useCache- Whether to use the cached version if available.- Returns:
- The FileConfiguration object for the specified configuration file.
-
getConfig
Get a configuration mapped to the specified configuration class.- Type Parameters:
T- The type of the configuration class.- Parameters:
configClass- The configuration class annotated with @PluginConfig.- Returns:
- An instance of the configuration class populated with values from the configuration file.
-
getConfig
Get a configuration mapped to the specified configuration class.- Type Parameters:
T- The type of the configuration class.- Parameters:
configClass- The configuration class annotated with @PluginConfig.useCache- Whether to use the cached version if available.- Returns:
- An instance of the configuration class populated with values from the configuration file.
-
saveConfig
Save a configuration file based on the provided PluginConfig enum.- Parameters:
config- The PluginConfig enum representing the configuration file to save.fileConfig- The FileConfiguration object to save.
-
saveConfig
Save a configuration file based on the provided file name.- Parameters:
fileName- The name of the configuration file (without the .yml extension).fileConfig- The FileConfiguration object to save.
-
clearCache
public void clearCache()Clear the configuration cache.
-