Class YamlConfigurationManager
java.lang.Object
net.mathias2246.buildmc.util.config.YamlConfigurationManager
An abstract utility-class for managing a configuration
-
Field Summary
FieldsModifier and TypeFieldDescriptionfinal org.bukkit.configuration.file.FileConfigurationThe configuration instance that is managed by this ConfigurationManager -
Constructor Summary
ConstructorsConstructorDescriptionYamlConfigurationManager(@NotNull org.bukkit.plugin.Plugin plugin, @NotNull String resourceName) -
Method Summary
Modifier and TypeMethodDescriptionprotected abstract voidpreSave()Executed before writing to diskvoidreload()voidsave()Saves the configuration to the current config file.voidSaves the default config from the plugins resources if the file doesn't existvoidsetConfigFile(@NotNull File file) Sets the file that this ConfigurationManager accesses.abstract voidExecuted when the config file gets loaded.
-
Field Details
-
configuration
public final org.bukkit.configuration.file.FileConfiguration configurationThe configuration instance that is managed by this ConfigurationManager
-
-
Constructor Details
-
YamlConfigurationManager
public YamlConfigurationManager(@NotNull @NotNull org.bukkit.plugin.Plugin plugin, @NotNull @NotNull String resourceName) - Parameters:
plugin- The plugin that owns this configurationresourceName- The name of the default configuration resource
-
-
Method Details
-
setConfigFile
Sets the file that this ConfigurationManager accesses. This also executes the setupConfiguration method to set up all the data after loading from the disk -
save
Saves the configuration to the current config file. Before saving, execute the preSave method with your logic of processing and formating the data that is saved.- Throws:
IOException
-
setupConfiguration
public abstract void setupConfiguration()Executed when the config file gets loaded. Used to set up all information. -
reload
public void reload() -
preSave
protected abstract void preSave()Executed before writing to disk -
saveFromResource
public void saveFromResource()Saves the default config from the plugins resources if the file doesn't exist
-