Class Config
- Direct Known Subclasses:
LanguageConfig
Slightly modified version of the one from the bukkit tutorial Source: http://wiki.bukkit.org/Configuration_API_Reference
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidaddSavable(ISavable savable, String basePath) Adds a savable object to the config for automatic savingvoidChecks the configuration for default values, copying default values over if they are not set.voidclear()Clears all of the data in the configstatic voidclear(org.bukkit.configuration.ConfigurationSection config) Clears all of the data in the configuration sectionvoiddeleteSavable(ISavable savable) Deletes the savable from the configorg.bukkit.configuration.file.FileConfigurationRetrieves the file of the configurationgetFile()org.bukkit.plugin.java.JavaPluginvoidReloads the configvoidsave()Saves if there are savables addedvoidSaves the configvoidSaves the default config if no file exists yetstatic voidsetDefaults(org.bukkit.configuration.ConfigurationSection config) Deprecated.use FileConfiguration.options().copyDefaults(true) insteadvoidtrim()Trims excess (non-default) values from the configurationstatic voidtrim(org.bukkit.configuration.ConfigurationSection config) A recursive method to trim the non-default values from a config
-
Constructor Details
-
Config
Constructor- Parameters:
plugin- plugin referencename- file name
-
-
Method Details
-
setDefaults
Deprecated.use FileConfiguration.options().copyDefaults(true) insteadA recursive method to set the defaults of the config
Only defaults that aren't set in the current config are copied over so that user changes aren't overwritten.
- Parameters:
config- config section to set the defaults for
-
trim
public static void trim(org.bukkit.configuration.ConfigurationSection config) A recursive method to trim the non-default values from a config
This is for clearing unnecessary values from settings configs
- Parameters:
config- configuration section to trim
-
clear
public static void clear(org.bukkit.configuration.ConfigurationSection config) Clears all of the data in the configuration section
This doesn't save the config so if you want the changes to be reflected in the actual file, call the saveConfig() method after doing this.
-
getPlugin
public org.bukkit.plugin.java.JavaPlugin getPlugin()- Returns:
- plugin owning this config file
-
getFile
- 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 saveConfig() method after doing this.
-
save
public void save()Saves if there are savables added -
addSavable
Adds a savable object to the config for automatic saving- Parameters:
savable- savable objectbasePath- base path for it
-
deleteSavable
Deletes the savable from the config- Parameters:
savable- savable to delete
-
reloadConfig
public void reloadConfig()Reloads the config -
getConfig
public org.bukkit.configuration.file.FileConfiguration getConfig()- Returns:
- config file
-
getConfigFile
Retrieves the file of the configuration
- Returns:
- the file of the configuration
-
saveConfig
public void saveConfig()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
-