Class ConfigManager

java.lang.Object
redempt.redlib.configmanager.ConfigManager

public class ConfigManager extends Object
Deprecated.
Old and poorly-designed API, use ConfigManager. This API will be removed in a future version.
Loads config values into variables annotated with ConfigValue
  • Constructor Summary

    Constructors
    Constructor
    Description
    Deprecated.
    Initiates a ConfigManager using a specific file for the config
    Deprecated.
    Initiates a ConfigManager using a specific path for the config
    ConfigManager(org.bukkit.plugin.Plugin plugin)
    Deprecated.
    Instantiates a ConfigManager with the default config name config.yml in the plugin's data folder
    ConfigManager(org.bukkit.plugin.Plugin plugin, String name)
    Deprecated.
    Instantiates a ConfigManager with a specific config name in the plugin's config folder
  • Method Summary

    Modifier and Type
    Method
    Description
    addConverter(Class<T> clazz, Function<String,T> load, Function<T,String> save)
    Deprecated.
    Adds a type converter, which will attempt to convert a String from config to another type that is not usually able to be stored in config
    static <T> ConfigCollection<T>
    collection(Class<T> clazz, Collection<T> toWrap, T... elements)
    Deprecated.
    Creates a ConfigCollection from a given type with initial elements.
    static <T> ConfigCollection<T>
    collection(Class<T> clazz, ConversionType type, Collection<T> toWrap, T... elements)
    Deprecated.
    Creates a ConfigCollection from a given type with initial elements.
    boolean
    Deprecated.
     
    org.bukkit.configuration.file.YamlConfiguration
    Deprecated.
     
    protected <T> redempt.redlib.configmanager.TypeConverter<T>
    getConverter(Class<T> clazz)
    Deprecated.
     
    static <T> redempt.redlib.configmanager.ConfigList<T>
    list(Class<T> clazz, ConversionType type, T... elements)
    Deprecated.
    Creates a ConfigList from a given type with initial elements.
    static <T> redempt.redlib.configmanager.ConfigList<T>
    list(Class<T> clazz, T... elements)
    Deprecated.
    Creates a ConfigList from a given type with initial elements.
    Deprecated.
    Loads all values from config into the annotated hook fields
    static <K, V> redempt.redlib.configmanager.ConfigMap<K,V>
    map(Class<K> keyClass, Class<V> valueClass)
    Deprecated.
    Creates a ConfigMap from a given type.
    static <K, V> redempt.redlib.configmanager.ConfigMap<K,V>
    map(Class<K> keyClass, Class<V> valueClass, ConversionType type)
    Deprecated.
    Creates a ConfigMap from a given type.
    static <T> redempt.redlib.configmanager.ConfigMap<String,T>
    map(Class<T> clazz)
    Deprecated.
    Creates a ConfigMap from a given type.
    static <T> redempt.redlib.configmanager.ConfigMap<String,T>
    map(Class<T> clazz, ConversionType type)
    Deprecated.
    Creates a ConfigMap from a given type.
    register(Object... data)
    Deprecated.
    Register all the hooks for annotated fields in the the given objects.
    Deprecated.
    Saves all values from the annotated hook fields to config
    Deprecated.
    Save default values - initial values in the hook fields - where they do not already exist in the config
    static <T> redempt.redlib.configmanager.ConfigSet<T>
    set(Class<T> clazz, ConversionType type, T... elements)
    Deprecated.
    Creates a ConfigSet from a given type with initial elements.
    static <T> redempt.redlib.configmanager.ConfigSet<T>
    set(Class<T> clazz, T... elements)
    Deprecated.
    Creates a ConfigSet from a given type with initial elements.
    static List<String>
    stringList(String... strings)
    Deprecated.
    Instantiates a List of Strings inline

    Methods inherited from class java.lang.Object

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

    • ConfigManager

      public ConfigManager(org.bukkit.plugin.Plugin plugin)
      Deprecated.
      Instantiates a ConfigManager with the default config name config.yml in the plugin's data folder
      Parameters:
      plugin - The plugin
    • ConfigManager

      public ConfigManager(org.bukkit.plugin.Plugin plugin, String name)
      Deprecated.
      Instantiates a ConfigManager with a specific config name in the plugin's config folder
      Parameters:
      plugin - The plugin
      name - The name of the config file to generate
    • ConfigManager

      public ConfigManager(File file)
      Deprecated.
      Initiates a ConfigManager using a specific file for the config
      Parameters:
      file - The file
    • ConfigManager

      public ConfigManager(Path path)
      Deprecated.
      Initiates a ConfigManager using a specific path for the config
      Parameters:
      path - The path
  • Method Details

    • stringList

      public static List<String> stringList(String... strings)
      Deprecated.
      Instantiates a List of Strings inline
      Parameters:
      strings - The Strings to include in the List
      Returns:
      The List of Strings
    • map

      public static <T> redempt.redlib.configmanager.ConfigMap<String,T> map(Class<T> clazz)
      Deprecated.
      Creates a ConfigMap from a given type. A ConfigMap extends LinkedHashMap. The class is not accessible, so store it in a HashMap variable. This method must be used to set the initial value for a variable which loads in a section from config.
      Type Parameters:
      T - The value type
      Parameters:
      clazz - The class of the value type
      Returns:
      An empty map of the given type, which will be populated when load() is called
    • map

      public static <T> redempt.redlib.configmanager.ConfigMap<String,T> map(Class<T> clazz, ConversionType type)
      Deprecated.
      Creates a ConfigMap from a given type. A ConfigMap extends LinkedHashMap. The class is not accessible, so store it in a HashMap variable. This method must be used to set the initial value for a variable which loads in a section from config.
      Type Parameters:
      T - The value type
      Parameters:
      clazz - The class of the value type
      type - The method which will be used to convert the stored type
      Returns:
      An empty map of the given type, which will be populated when load() is called
    • map

      public static <K, V> redempt.redlib.configmanager.ConfigMap<K,V> map(Class<K> keyClass, Class<V> valueClass)
      Deprecated.
      Creates a ConfigMap from a given type. A ConfigMap extends LinkedHashMap. The class is not accessible, so store it in a HashMap variable. This method must be used to set the initial value for a variable which loads in a section from config. The key class may only be a type which has converter from string to another type. For obvious reasons, it cannot be a config-mappable object.
      Type Parameters:
      K - The key type
      V - The value type
      Parameters:
      keyClass - The class of the key type
      valueClass - The class of the value type
      Returns:
      An empty map of the given type, which will be populated when load() is called
    • map

      public static <K, V> redempt.redlib.configmanager.ConfigMap<K,V> map(Class<K> keyClass, Class<V> valueClass, ConversionType type)
      Deprecated.
      Creates a ConfigMap from a given type. A ConfigMap extends LinkedHashMap. The class is not accessible, so store it in a HashMap variable. This method must be used to set the initial value for a variable which loads in a section from config. The key class may only be a type which has converter from string to another type. For obvious reasons, it cannot be a config-mappable object.
      Type Parameters:
      K - The key type
      V - The value type
      Parameters:
      keyClass - The class of the key type
      valueClass - The class of the value type
      type - The method which will be used to convert the value type
      Returns:
      An empty map of the given type, which will be populated when load() is called
    • list

      public static <T> redempt.redlib.configmanager.ConfigList<T> list(Class<T> clazz, T... elements)
      Deprecated.
      Creates a ConfigList from a given type with initial elements. A ConfigList extends ArrayList. The class is not accessible, so store it in an ArrayList variable. This method must be used to set the initial value for a variable which loads a list from config using type converters or mapped objects.
      Type Parameters:
      T - The type
      Parameters:
      clazz - The class of the type of the list
      elements - The elements to initialize the list with
      Returns:
      A list of the given type which has been populated with the given elements
    • list

      public static <T> redempt.redlib.configmanager.ConfigList<T> list(Class<T> clazz, ConversionType type, T... elements)
      Deprecated.
      Creates a ConfigList from a given type with initial elements. A ConfigList extends ArrayList. The class is not accessible, so store it in an ArrayList variable. This method must be used to set the initial value for a variable which loads a list from config using type converters or mapped objects.
      Type Parameters:
      T - The type
      Parameters:
      clazz - The class of the type of the list
      elements - The elements to initialize the list with
      type - The method which will be used to convert the stored type
      Returns:
      A list of the given type which has been populated with the given elements
    • set

      public static <T> redempt.redlib.configmanager.ConfigSet<T> set(Class<T> clazz, T... elements)
      Deprecated.
      Creates a ConfigSet from a given type with initial elements. A ConfigSet extends LinkedHashSet. The class is not accessible, so store it in a HashSet variable. This method must be used to set the initial value for a variable which loads a set from config using type converters or mapped objects.
      Type Parameters:
      T - The type
      Parameters:
      clazz - The class of the type of the list
      elements - The elements to initialize the list with
      Returns:
      A set of the given type which has been populated with the given elements
    • set

      public static <T> redempt.redlib.configmanager.ConfigSet<T> set(Class<T> clazz, ConversionType type, T... elements)
      Deprecated.
      Creates a ConfigSet from a given type with initial elements. A ConfigSet extends LinkedHashSet. The class is not accessible, so store it in a HashSet variable. This method must be used to set the initial value for a variable which loads a set from config using type converters or mapped objects.
      Type Parameters:
      T - The type
      Parameters:
      clazz - The class of the type of the list
      elements - The elements to initialize the list with
      type - The method which will be used to convert the stored type
      Returns:
      A set of the given type which has been populated with the given elements
    • collection

      public static <T> ConfigCollection<T> collection(Class<T> clazz, ConversionType type, Collection<T> toWrap, T... elements)
      Deprecated.
      Creates a ConfigCollection from a given type with initial elements. A ConfigCollection wraps the given collection. This method must be used to set the initial value for a variable which loads a set from config using type converters or mapped objects.
      Type Parameters:
      T - The type
      Parameters:
      clazz - The class of the type of the list
      elements - The elements to initialize the list with
      type - The method which will be used to convert the stored type
      toWrap - The Collection to wrap
      Returns:
      A wrapped collection of the given type which has been populated with the given elements
    • collection

      public static <T> ConfigCollection<T> collection(Class<T> clazz, Collection<T> toWrap, T... elements)
      Deprecated.
      Creates a ConfigCollection from a given type with initial elements. A ConfigCollection wraps the given collection. This method must be used to set the initial value for a variable which loads a set from config using type converters or mapped objects.
      Type Parameters:
      T - The type
      Parameters:
      clazz - The class of the type of the list
      elements - The elements to initialize the list with
      toWrap - The Collection to wrap
      Returns:
      A wrapped collection of the given type which has been populated with the given elements
    • addConverter

      public <T> ConfigManager addConverter(Class<T> clazz, Function<String,T> load, Function<T,String> save)
      Deprecated.
      Adds a type converter, which will attempt to convert a String from config to another type that is not usually able to be stored in config
      Type Parameters:
      T - The type
      Parameters:
      clazz - The class of the type
      load - A function to convert from a string to the type
      save - A function to convert from the type to a string
      Returns:
      This ConfigManager
    • getConverter

      protected <T> redempt.redlib.configmanager.TypeConverter<T> getConverter(Class<T> clazz)
      Deprecated.
    • register

      public ConfigManager register(Object... data)
      Deprecated.
      Register all the hooks for annotated fields in the the given objects. Pass classes instead if static fields are used.
      Parameters:
      data - The object to be registered
      Returns:
      This ConfigManager
    • configExists

      public boolean configExists()
      Deprecated.
      Returns:
      Whether the config file exists
    • saveDefaults

      public ConfigManager saveDefaults()
      Deprecated.
      Save default values - initial values in the hook fields - where they do not already exist in the config
      Returns:
      This ConfigManager
      Throws:
      IllegalStateException - if this ConfigManager has not been registered yet
    • load

      public ConfigManager load()
      Deprecated.
      Loads all values from config into the annotated hook fields
      Returns:
      This ConfigManager
      Throws:
      IllegalStateException - if this ConfigManager has not been registered yet
    • save

      public ConfigManager save()
      Deprecated.
      Saves all values from the annotated hook fields to config
      Returns:
      This ConfigManager
      Throws:
      IllegalStateException - if this ConfigManager has not been registered yet
    • getConfig

      public org.bukkit.configuration.file.YamlConfiguration getConfig()
      Deprecated.
      Returns:
      The configuration this ConfigManager is loading from and saving to