Class ConfigUtils
java.lang.Object
me.despical.commons.configuration.ConfigUtils
- Author:
- Despical
Created at 30.05.2020
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic org.bukkit.configuration.file.FileConfigurationGet the config file's configurationstatic org.bukkit.configuration.file.FileConfigurationgetConfigFromResources(org.bukkit.plugin.java.JavaPlugin plugin, String fileName) Get the config file's configuration, gets the file from the resources.static voidsaveConfig(org.bukkit.plugin.java.JavaPlugin plugin, org.bukkit.configuration.file.FileConfiguration config, String name) Save specified config file.static voidwriteAndSave(org.bukkit.plugin.java.JavaPlugin plugin, String fileName, Consumer<org.bukkit.configuration.file.FileConfiguration> configConsumer) Retrieves, modifies, and saves a configuration file for the given plugin.
-
Constructor Details
-
ConfigUtils
public ConfigUtils()
-
-
Method Details
-
getConfig
public static org.bukkit.configuration.file.FileConfiguration getConfig(org.bukkit.plugin.java.JavaPlugin plugin, String fileName) Get the config file's configuration- Parameters:
plugin- to get config file fromfileName- name of the config file- Returns:
- file configuration of given file
-
getConfigFromResources
public static org.bukkit.configuration.file.FileConfiguration getConfigFromResources(org.bukkit.plugin.java.JavaPlugin plugin, String fileName) Get the config file's configuration, gets the file from the resources.- Parameters:
plugin- to get config file fromfileName- name of the config file- Returns:
- file configuration of given file
-
saveConfig
public static void saveConfig(org.bukkit.plugin.java.JavaPlugin plugin, org.bukkit.configuration.file.FileConfiguration config, String name) Save specified config file.- Parameters:
plugin- to get config file fromconfig- file to savename- to get config
-
writeAndSave
public static void writeAndSave(org.bukkit.plugin.java.JavaPlugin plugin, String fileName, Consumer<org.bukkit.configuration.file.FileConfiguration> configConsumer) Retrieves, modifies, and saves a configuration file for the given plugin.This method loads a configuration file using the provided
fileName, applies modifications through the specifiedConsumerofFileConfiguration, and then saves the modified configuration file.- Parameters:
plugin- TheJavaPlugininstance from which the configuration is loaded and saved.fileName- The name of the configuration file to be loaded and saved.configConsumer- AConsumerthat performs operations on theFileConfiguration. This allows you to modify the configuration before it is saved.
-