Class ConfigService

java.lang.Object
com.zetaplugins.zetacore.services.config.ConfigService

public class ConfigService extends Object
Service for managing plugin configuration files with caching support.
  • Constructor Details

    • ConfigService

      public ConfigService(JavaPlugin plugin)
      Construct a new ConfigService.
      Parameters:
      plugin - The JavaPlugin instance.
  • Method Details

    • getConfig

      public FileConfiguration getConfig(PluginConfigFile config)
      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

      public FileConfiguration getConfig(PluginConfigFile config, boolean useCache)
      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

      public FileConfiguration getConfig(String fileName)
      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

      public FileConfiguration getConfig(String fileName, boolean useCache)
      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

      public <T> T getConfig(Class<T> configClass)
      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

      public <T> T getConfig(Class<T> configClass, boolean useCache)
      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

      public void saveConfig(PluginConfigFile config, FileConfiguration fileConfig)
      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

      public void saveConfig(String fileName, FileConfiguration fileConfig)
      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.