Class CommentedConfig
java.lang.Object
studio.magemonkey.codex.mccore.config.CommentedConfig
- Direct Known Subclasses:
CommentedLanguageConfig
Handles configs with comment and UTF-8 support. Can be used
to handle config.yml to preserve/manage comments as well.
-
Constructor Summary
ConstructorsConstructorDescriptionCommentedConfig(org.bukkit.plugin.java.JavaPlugin plugin, String name) Constructor -
Method Summary
Modifier and TypeMethodDescriptionvoidChecks the configuration for default values, copying default values over if they are not set.voidclear()Clears all of the data in the configRetrieves the file of the configurationorg.bukkit.plugin.java.JavaPluginvoidreload()Reloads the config datavoidsave()Saves the configvoidSaves the default config if no file exists yetvoidtrim()Trims excess (non-default) values from the configuration
-
Constructor Details
-
CommentedConfig
Constructor- Parameters:
plugin- plugin referencename- file name
-
-
Method Details
-
getFileName
- Returns:
- name of the file this config saves to
-
clear
public void clear()Clears all of the data in the config
This doesn't save the config so if you want the changes to be reflected in the actual file, call the save() method after doing this.
-
reload
public void reload()Reloads the config data -
getConfig
- Returns:
- config file
-
save
public void save()Saves the config -
saveDefaultConfig
public void saveDefaultConfig()Saves the default config if no file exists yet -
checkDefaults
public void checkDefaults()Checks the configuration for default values, copying default values over if they are not set. Once finished, the config is saved so the user can see the changes.
This acts differently than saveDefaultConfig() as the config can already exist for this method. This is more for making sure users do not erase needed values from settings configs.
-
trim
public void trim()Trims excess (non-default) values from the configuration
Any values that weren't in the default configuration are removed
This is primarily used for settings configs
-
getPlugin
public org.bukkit.plugin.java.JavaPlugin getPlugin()- Returns:
- plugin owning this config file
-
getConfigFile
Retrieves the file of the configuration
- Returns:
- the file of the configuration
-