Class ConfigManager

java.lang.Object
redempt.redlib.config.ConfigManager

public class ConfigManager extends Object
Serializes and deserializes configuration data into objects and fields
  • Method Details

    • areCommentsSupported

      public static boolean areCommentsSupported()
      Returns:
      Whether comments are supported in this version
    • create

      public static ConfigManager create(org.bukkit.plugin.Plugin plugin, File file)
      Creates a ConfigManager targetting a specific config file, which will be created if it does not exist
      Parameters:
      plugin - The plugin the ConfigManager belongs to
      file - The config file to manage
      Returns:
      The ConfigManager
    • create

      public static ConfigManager create(org.bukkit.plugin.Plugin plugin, Path path)
      Creates a ConfigManager targetting a specific config file, which will be created if it does not exist
      Parameters:
      plugin - The plugin the ConfigManager belongs to
      path - The config file to manage
      Returns:
      The ConfigManager
    • create

      public static ConfigManager create(org.bukkit.plugin.Plugin plugin, String configName)
      Creates a ConfigManager for a file in a plugin's data folder
      Parameters:
      plugin - The plugin whose data folder should be used
      configName - The name of the config file to manage
      Returns:
      The ConfigManager
    • create

      public static ConfigManager create(org.bukkit.plugin.Plugin plugin)
      Creates a ConfigManager for the default config in a plugin's data folder, called config.yml
      Parameters:
      plugin - The plugin whose data folder should be used
      Returns:
      The ConfigManager
    • getConversionManager

      public ConversionManager getConversionManager()
      Returns:
      The ConversionManager responsible for storing and creating converters for this ConfigManager
    • setConversionManager

      public void setConversionManager(ConversionManager conversionManager)
      Sets the ConversionManager responsible for storing and creating converters for this ConfigManager
      Parameters:
      conversionManager - The ConversionManager
    • addConverter

      public <T> ConfigManager addConverter(Class<T> clazz, Function<String,T> loader, Function<T,String> saver)
      Registers a string converter to this ConfigManager
      Type Parameters:
      T - The type
      Parameters:
      clazz - The class type the converter is for
      loader - A function to convert a string to the given type
      saver - A function to convert the given type to a string
      Returns:
      This ConfigManager
    • addConverter

      public <T> ConfigManager addConverter(ConfigType<T> type, TypeConverter<T> converter)
      Registers a converter to this ConfigManager
      Type Parameters:
      T - The type
      Parameters:
      type - The type the converter is for
      converter - The converter
      Returns:
      This ConfigManager
    • target

      public ConfigManager target(Object obj)
      Specifies the given Object to load config values to and save config values from. The Object must be from a ConfigMappable class, and all of its non-transient fields will be worked with.
      Parameters:
      obj - The Object to operate on
      Returns:
      This ConfigManager
    • target

      public ConfigManager target(Class<?> clazz)
      Specifies the given Class to load config values to and save config values from. The Class's static non-transient fields will be worked with.
      Parameters:
      clazz - The Class to operate on
      Returns:
      This ConfigManager
    • save

      public ConfigManager save()
      Saves all of the values from the target to config
      Returns:
      This ConfigManager
    • saveDefaults

      public ConfigManager saveDefaults()
      Saves only values which are not already specified in config
      Returns:
      This ConfigManager
    • load

      public ConfigManager load()
      Loads all values from the current in-memory config into the target
      Returns:
      This ConfigManager
    • reload

      public ConfigManager reload()
      Loads the config from disk, then loads all values into the target
      Returns:
      This ConfigManager
    • getConfig

      public org.bukkit.configuration.file.FileConfiguration getConfig()
      Returns:
      The configuration file wrapped by this ConfigManager