Class ConfigFileWrapper
java.lang.Object
de.eldoria.eldoutilities.configuration.ConfigFileWrapper
A simple wrapper to manage File configurations.
-
Method Summary
Modifier and TypeMethodDescriptionstatic ConfigFileWrapper
Create a config for a file.static ConfigFileWrapper
Create a config for a filestatic ConfigFileWrapper
Create a config for a filestatic ConfigFileWrapper
forFileWithDefaults
(Plugin plugin, String filePath, @Nullable Configuration defaultConfig) Create a config for a filestatic ConfigFileWrapper
Create a config for a filestatic ConfigFileWrapper
forFileWithDefaults
(Plugin plugin, Path filePath, @Nullable Configuration defaultConfig) Create a config for a filestatic ConfigFileWrapper
Create a config for a fileget()
Get the file configuration.void
reload()
Reload the config file from diskvoid
save()
Save the config file to diskvoid
write
(Consumer<FileConfiguration> consumer) Write data to the config with a consumer
-
Method Details
-
forFile
Create a config for a file- Parameters:
plugin
- owner of the configfilePath
- path to file- Returns:
- new instance
-
forFile
Create a config for a file- Parameters:
plugin
- owner of the configfilePath
- path to file- Returns:
- new instance
-
forFile
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 configfilePath
- path to filedefaultMap
- 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 configfilePath
- path to filedefaultMap
- 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 configfilePath
- path to filedefaultConfig
- 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 configfilePath
- path to filedefaultConfig
- a configuration with default values to set.- Returns:
- new instance
-
get
Get the file configuration.Should not be cached.
- Returns:
- file configuration
-
write
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
-