Class ConfigManager<T>

java.lang.Object
net.darkhax.pricklemc.common.api.config.ConfigManager<T>

public class ConfigManager<T> extends Object
  • Method Details

    • load

      public static <T> T load(String name, T defaultValue)
      Creates and loads a configuration file.
      Type Parameters:
      T - The type of the config object.
      Parameters:
      name - The name of the config file. This file will use the platforms config directory.
      defaultValue - The default config value.
      Returns:
      The config object that was loaded.
    • load

      public static <T> T load(String name, T defaultValue, @Nullable @Nullable Consumer<ConfigManager.Builder<T>> configure)
      Creates and loads a configuration file.
      Type Parameters:
      T - The type of the config object.
      Parameters:
      name - The name of the config file. This file will use the platforms config directory.
      defaultValue - The default config value.
      configure - An optional consumer used to configure the builder before it is built.
      Returns:
      The config object that was loaded.
    • init

      public static <T> ConfigManager<T> init(String name, T defaultValue)
      Initializes a config manager with the default plugins.
      Type Parameters:
      T - The type of object held by the config manager.
      Parameters:
      name - The name of the config file. This file will use the platforms config directory.
      defaultValue - The default config value.
      Returns:
      A new config manager.
    • init

      public static <T> ConfigManager<T> init(String name, T defaultValue, @Nullable @Nullable Consumer<ConfigManager.Builder<T>> configure)
      Initializes a config manager with the default plugins and extra user configurations applied.
      Type Parameters:
      T - The type of object held by the config manager.
      Parameters:
      name - The name of the config file. This file will use the platforms config directory.
      defaultValue - The default config value.
      configure - An optional consumer used to configure the builder before it is built.
      Returns:
      A new config manager.
    • load

      public void load()
      Loads the config file from disk. If the file does not exist it will try to generate one using the schema that was mapped out when building the config manager.
    • save

      public void save()
      Saves the config object to the specified file path. If the file does not exist one will be created.
    • get

      public T get()
      Gets the object being managed.
      Returns:
      The config object being managed.