Class ConfigFileWrapper

java.lang.Object
de.eldoria.eldoutilities.configuration.ConfigFileWrapper

public final class ConfigFileWrapper extends Object
A simple wrapper to manage File configurations.
  • Method Details

    • forFile

      public static ConfigFileWrapper forFile(Plugin plugin, String filePath)
      Create a config for a file
      Parameters:
      plugin - owner of the config
      filePath - path to file
      Returns:
      new instance
    • forFile

      public static ConfigFileWrapper forFile(Plugin plugin, Path filePath)
      Create a config for a file
      Parameters:
      plugin - owner of the config
      filePath - path to file
      Returns:
      new instance
    • forFile

      public static ConfigFileWrapper forFile(Path filePath)
      Create a config for a file. This file is not owned by any plugin. The path will be relative to the plugin directory itself.
      Parameters:
      filePath - path to file
      Returns:
      new instance
    • forFileWithDefaults

      public static ConfigFileWrapper forFileWithDefaults(Plugin plugin, String filePath, Map<String,Object> defaultMap)
      Create a config for a file
      Parameters:
      plugin - owner of the config
      filePath - path to file
      defaultMap - a map with default values to set.
      Returns:
      new instance
    • forFileWithDefaults

      public static ConfigFileWrapper forFileWithDefaults(Plugin plugin, Path filePath, Map<String,Object> defaultMap)
      Create a config for a file
      Parameters:
      plugin - owner of the config
      filePath - path to file
      defaultMap - a map with default values to set.
      Returns:
      new instance
    • forFileWithDefaults

      public static ConfigFileWrapper forFileWithDefaults(Plugin plugin, String filePath, @Nullable @Nullable Configuration defaultConfig)
      Create a config for a file
      Parameters:
      plugin - owner of the config
      filePath - path to file
      defaultConfig - a configuration with default values to set.
      Returns:
      new instance
    • forFileWithDefaults

      public static ConfigFileWrapper forFileWithDefaults(Plugin plugin, Path filePath, @Nullable @Nullable Configuration defaultConfig)
      Create a config for a file
      Parameters:
      plugin - owner of the config
      filePath - path to file
      defaultConfig - a configuration with default values to set.
      Returns:
      new instance
    • get

      public FileConfiguration get()
      Get the file configuration.

      Should not be cached.

      Returns:
      file configuration
    • write

      public void write(Consumer<FileConfiguration> consumer)
      Write data to the config with a consumer
      Parameters:
      consumer - consumer to apply
    • save

      public void save()
      Save the config file to disk
    • reload

      public void reload()
      Reload the config file from disk