Package redempt.redlib.config
Class ConfigManager
java.lang.Object
redempt.redlib.config.ConfigManager
Serializes and deserializes configuration data into objects and fields
-
Method Summary
Modifier and TypeMethodDescription<T> ConfigManagerRegisters a string converter to this ConfigManager<T> ConfigManageraddConverter(ConfigType<T> type, TypeConverter<T> converter) Registers a converter to this ConfigManagerstatic booleanstatic ConfigManagercreate(org.bukkit.plugin.Plugin plugin) Creates a ConfigManager for the default config in a plugin's data folder, called config.ymlstatic ConfigManagerCreates a ConfigManager targetting a specific config file, which will be created if it does not existstatic ConfigManagerCreates a ConfigManager for a file in a plugin's data folderstatic ConfigManagerCreates a ConfigManager targetting a specific config file, which will be created if it does not existorg.bukkit.configuration.file.FileConfigurationload()Loads all values from the current in-memory config into the targetreload()Loads the config from disk, then loads all values into the targetsave()Saves all of the values from the target to configSaves only values which are not already specified in configvoidsetConversionManager(ConversionManager conversionManager) Sets the ConversionManager responsible for storing and creating converters for this ConfigManagerSpecifies the given Class to load config values to and save config values from.Specifies the given Object to load config values to and save config values from.
-
Method Details
-
areCommentsSupported
public static boolean areCommentsSupported()- Returns:
- Whether comments are supported in this version
-
create
Creates a ConfigManager targetting a specific config file, which will be created if it does not exist- Parameters:
plugin- The plugin the ConfigManager belongs tofile- The config file to manage- Returns:
- The ConfigManager
-
create
Creates a ConfigManager targetting a specific config file, which will be created if it does not exist- Parameters:
plugin- The plugin the ConfigManager belongs topath- The config file to manage- Returns:
- The ConfigManager
-
create
Creates a ConfigManager for a file in a plugin's data folder- Parameters:
plugin- The plugin whose data folder should be usedconfigName- The name of the config file to manage- Returns:
- The ConfigManager
-
create
Creates a ConfigManager for the default config in a plugin's data folder, called config.yml- Parameters:
plugin- The plugin whose data folder should be used- Returns:
- The ConfigManager
-
getConversionManager
- Returns:
- The ConversionManager responsible for storing and creating converters for this ConfigManager
-
setConversionManager
Sets the ConversionManager responsible for storing and creating converters for this ConfigManager- Parameters:
conversionManager- The ConversionManager
-
addConverter
public <T> ConfigManager addConverter(Class<T> clazz, Function<String, T> loader, Function<T, String> saver) Registers a string converter to this ConfigManager- Type Parameters:
T- The type- Parameters:
clazz- The class type the converter is forloader- A function to convert a string to the given typesaver- A function to convert the given type to a string- Returns:
- This ConfigManager
-
addConverter
Registers a converter to this ConfigManager- Type Parameters:
T- The type- Parameters:
type- The type the converter is forconverter- The converter- Returns:
- This ConfigManager
-
target
Specifies the given Object to load config values to and save config values from. The Object must be from a ConfigMappable class, and all of its non-transient fields will be worked with.- Parameters:
obj- The Object to operate on- Returns:
- This ConfigManager
-
target
Specifies the given Class to load config values to and save config values from. The Class's static non-transient fields will be worked with.- Parameters:
clazz- The Class to operate on- Returns:
- This ConfigManager
-
save
Saves all of the values from the target to config- Returns:
- This ConfigManager
-
saveDefaults
Saves only values which are not already specified in config- Returns:
- This ConfigManager
-
load
Loads all values from the current in-memory config into the target- Returns:
- This ConfigManager
-
reload
Loads the config from disk, then loads all values into the target- Returns:
- This ConfigManager
-
getConfig
public org.bukkit.configuration.file.FileConfiguration getConfig()- Returns:
- The configuration file wrapped by this ConfigManager
-