Class YamlConfiguration
- All Implemented Interfaces:
Configuration,ConfigurationSection
public class YamlConfiguration extends FileConfiguration
Configuration which saves all files in Yaml.
Note that this implementation is not synchronized.-
Field Summary
Fields Modifier and Type Field Description protected static java.lang.StringBLANK_CONFIGprotected static java.lang.StringCOMMENT_PREFIXFields inherited from class org.bukkit.configuration.file.FileConfiguration
SYSTEM_UTF, UTF_BIG, UTF8_OVERRIDE -
Constructor Summary
Constructors Constructor Description YamlConfiguration() -
Method Summary
Modifier and Type Method Description protected java.lang.StringbuildHeader()Compiles the header for thisFileConfigurationand returns the result.protected voidconvertMapsToSections(java.util.Map<?,?> input, ConfigurationSection section)static YamlConfigurationloadConfiguration(java.io.File file)Creates a newYamlConfiguration, loading from the given file.static YamlConfigurationloadConfiguration(java.io.InputStream stream)Deprecated.does not properly consider encodingstatic YamlConfigurationloadConfiguration(java.io.Reader reader)Creates a newYamlConfiguration, loading from the given reader.voidloadFromString(java.lang.String contents)Loads thisFileConfigurationfrom the specified string, as opposed to from file.YamlConfigurationOptionsoptions()Gets theConfigurationOptionsfor thisConfiguration.protected java.lang.StringparseHeader(java.lang.String input)java.lang.StringsaveToString()Saves thisFileConfigurationto a string, and returns it.Methods inherited from class org.bukkit.configuration.file.FileConfiguration
load, load, load, load, save, saveMethods inherited from class org.bukkit.configuration.MemoryConfiguration
addDefault, addDefaults, addDefaults, getDefaults, getParent, setDefaultsMethods inherited from class org.bukkit.configuration.MemorySection
contains, createPath, createPath, createSection, createSection, get, get, getBoolean, getBoolean, getBooleanList, getByteList, getCharacterList, getColor, getColor, getConfigurationSection, getCurrentPath, getDefault, getDefaultSection, getDouble, getDouble, getDoubleList, getFloatList, getInt, getInt, getIntegerList, getItemStack, getItemStack, getKeys, getList, getList, getLong, getLong, getLongList, getMapList, getName, getOfflinePlayer, getOfflinePlayer, getRoot, getShortList, getString, getString, getStringList, getValues, getVector, getVector, isBoolean, isColor, isConfigurationSection, isDouble, isInt, isItemStack, isList, isLong, isOfflinePlayer, isPrimitiveWrapper, isSet, isString, isVector, mapChildrenKeys, mapChildrenValues, set, toStringMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface org.bukkit.configuration.ConfigurationSection
contains, createSection, createSection, get, get, getBoolean, getBoolean, getBooleanList, getByteList, getCharacterList, getColor, getColor, getConfigurationSection, getCurrentPath, getDefaultSection, getDouble, getDouble, getDoubleList, getFloatList, getInt, getInt, getIntegerList, getItemStack, getItemStack, getKeys, getList, getList, getLong, getLong, getLongList, getMapList, getName, getOfflinePlayer, getOfflinePlayer, getRoot, getShortList, getString, getString, getStringList, getValues, getVector, getVector, isBoolean, isColor, isConfigurationSection, isDouble, isInt, isItemStack, isList, isLong, isOfflinePlayer, isSet, isString, isVector, set
-
Field Details
-
COMMENT_PREFIX
protected static final java.lang.String COMMENT_PREFIX- See Also:
- Constant Field Values
-
BLANK_CONFIG
protected static final java.lang.String BLANK_CONFIG- See Also:
- Constant Field Values
-
-
Constructor Details
-
YamlConfiguration
public YamlConfiguration()
-
-
Method Details
-
saveToString
public java.lang.String saveToString()Description copied from class:FileConfigurationSaves thisFileConfigurationto a string, and returns it.- Specified by:
saveToStringin classFileConfiguration- Returns:
- String containing this configuration.
-
loadFromString
Description copied from class:FileConfigurationLoads thisFileConfigurationfrom the specified string, as opposed to from file.All the values contained within this configuration will be removed, leaving only settings and defaults, and the new values will be loaded from the given string.
If the string is invalid in any way, an exception will be thrown.
- Specified by:
loadFromStringin classFileConfiguration- Parameters:
contents- Contents of a Configuration to load.- Throws:
InvalidConfigurationException- Thrown if the specified string is invalid.
-
convertMapsToSections
-
parseHeader
protected java.lang.String parseHeader(java.lang.String input) -
buildHeader
protected java.lang.String buildHeader()Description copied from class:FileConfigurationCompiles the header for thisFileConfigurationand returns the result.This will use the header from
FileConfiguration.options()->FileConfigurationOptions.header(), respecting the rules ofFileConfigurationOptions.copyHeader()if set.- Specified by:
buildHeaderin classFileConfiguration- Returns:
- Compiled header
-
options
Description copied from interface:ConfigurationGets theConfigurationOptionsfor thisConfiguration.All setters through this method are chainable.
- Specified by:
optionsin interfaceConfiguration- Overrides:
optionsin classFileConfiguration- Returns:
- Options for this configuration
-
loadConfiguration
Creates a newYamlConfiguration, loading from the given file.Any errors loading the Configuration will be logged and then ignored. If the specified input is not a valid config, a blank config will be returned.
The encoding used may follow the system dependent default.
- Parameters:
file- Input file- Returns:
- Resulting configuration
- Throws:
java.lang.IllegalArgumentException- Thrown if file is null
-
loadConfiguration
Deprecated.does not properly consider encodingCreates a newYamlConfiguration, loading from the given stream.Any errors loading the Configuration will be logged and then ignored. If the specified input is not a valid config, a blank config will be returned.
- Parameters:
stream- Input stream- Returns:
- Resulting configuration
- Throws:
java.lang.IllegalArgumentException- Thrown if stream is null- See Also:
FileConfiguration.load(InputStream),loadConfiguration(Reader)
-
loadConfiguration
Creates a newYamlConfiguration, loading from the given reader.Any errors loading the Configuration will be logged and then ignored. If the specified input is not a valid config, a blank config will be returned.
- Parameters:
reader- input- Returns:
- resulting configuration
- Throws:
java.lang.IllegalArgumentException- Thrown if stream is null
-