Class ConfigManager
java.lang.Object
com.github.pinont.singularitylib.api.manager.ConfigManager
Manages configuration files for the plugin.
This class provides functionality to create, load, save, and manipulate YAML configuration files.
-
Constructor Summary
ConstructorsConstructorDescriptionConfigManager(org.bukkit.plugin.Plugin plugin, String fileName) Creates a ConfigManager for a configuration file in the plugin's data folder.ConfigManager(org.bukkit.plugin.Plugin plugin, String subFolder, String fileName) Creates a ConfigManager for a configuration file in a specific subfolder. -
Method Summary
Modifier and TypeMethodDescriptionGets a value from the specified path in the configuration.org.bukkit.configuration.file.FileConfigurationGets the FileConfiguration instance.static booleanChecks if a configuration file exists in a specific subfolder.booleanChecks if this is the first time the configuration file is being loaded.voidReloads the configuration from disk.voidSaves the configuration to the file.voidSets a value at the specified path in the configuration.
-
Constructor Details
-
ConfigManager
Creates a ConfigManager for a configuration file in the plugin's data folder.- Parameters:
fileName- the name of the configuration file
-
ConfigManager
-
-
Method Details
-
isExists
Checks if a configuration file exists in a specific subfolder.- Parameters:
subFolder- the subfolder to check infileName- the name of the configuration file- Returns:
- true if the file exists, false otherwise
-
set
-
get
-
saveConfig
public void saveConfig()Saves the configuration to the file. This method writes all changes made to the configuration back to the file. -
getConfig
public org.bukkit.configuration.file.FileConfiguration getConfig()Gets the FileConfiguration instance.- Returns:
- the FileConfiguration instance, or null if there was an error loading
-
reloadConfig
public void reloadConfig()Reloads the configuration from disk.Useful when the file is manually modified while the server is running.
-
isFirstLoad
public boolean isFirstLoad()Checks if this is the first time the configuration file is being loaded.- Returns:
- true if this is the first load (file was just created), false otherwise
-