Class FileConfiguration
- All Implemented Interfaces:
Configuration
,ConfigurationSection
- Direct Known Subclasses:
YamlConfiguration
Configuration
-
Field Summary
Fields inherited from class org.bukkit.configuration.MemoryConfiguration
defaults, options
Fields inherited from class org.bukkit.configuration.MemorySection
map
-
Constructor Summary
ConstructorDescriptionCreates an emptyFileConfiguration
with no default values.FileConfiguration
(@Nullable Configuration defaults) Creates an emptyFileConfiguration
using the specifiedConfiguration
as a source for all default values. -
Method Summary
Modifier and TypeMethodDescriptionDeprecated.This method only exists for backwards compatibility.void
Loads thisFileConfiguration
from the specified location.void
Loads thisFileConfiguration
from the specified reader.void
Loads thisFileConfiguration
from the specified location.abstract void
loadFromString
(@NotNull String contents) Loads thisFileConfiguration
from the specified string, as opposed to from file.options()
Gets theConfigurationOptions
for thisConfiguration
.void
Saves thisFileConfiguration
to the specified location.void
Saves thisFileConfiguration
to the specified location.Saves thisFileConfiguration
to a string, and returns it.Methods inherited from class org.bukkit.configuration.MemoryConfiguration
addDefault, addDefaults, addDefaults, getDefaults, getParent, setDefaults
Methods inherited from class org.bukkit.configuration.MemorySection
contains, contains, createPath, createPath, createSection, createSection, get, get, getBoolean, getBoolean, getBooleanList, getByteList, getCharacterList, getColor, getColor, getComments, getConfigurationSection, getCurrentPath, getDefault, getDefaultSection, getDouble, getDouble, getDoubleList, getFloatList, getInlineComments, getInt, getInt, getIntegerList, getItemStack, getItemStack, getKeys, getList, getList, getLocation, getLocation, getLong, getLong, getLongList, getMapList, getName, getObject, getObject, getOfflinePlayer, getOfflinePlayer, getRoot, getSerializable, getSerializable, getShortList, getString, getString, getStringList, getValues, getVector, getVector, isBoolean, isColor, isConfigurationSection, isDouble, isInt, isItemStack, isList, isLocation, isLong, isOfflinePlayer, isPrimitiveWrapper, isSet, isString, isVector, mapChildrenKeys, mapChildrenValues, set, setComments, setInlineComments, toString
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface org.bukkit.configuration.ConfigurationSection
contains, contains, createSection, createSection, get, get, getBoolean, getBoolean, getBooleanList, getByteList, getCharacterList, getColor, getColor, getComments, getComponent, getComponent, getConfigurationSection, getCurrentPath, getDefaultSection, getDouble, getDouble, getDoubleList, getFloatList, getInlineComments, getInt, getInt, getIntegerList, getItemStack, getItemStack, getKeys, getList, getList, getLocation, getLocation, getLong, getLong, getLongList, getMapList, getName, getObject, getObject, getOfflinePlayer, getOfflinePlayer, getRichMessage, getRichMessage, getRoot, getSerializable, getSerializable, getShortList, getString, getString, getStringList, getValues, getVector, getVector, isBoolean, isColor, isConfigurationSection, isDouble, isInt, isItemStack, isList, isLocation, isLong, isOfflinePlayer, isSet, isString, isVector, set, setComments, setComponent, setInlineComments, setRichMessage
-
Constructor Details
-
FileConfiguration
public FileConfiguration()Creates an emptyFileConfiguration
with no default values. -
FileConfiguration
Creates an emptyFileConfiguration
using the specifiedConfiguration
as a source for all default values.- Parameters:
defaults
- Default value provider
-
-
Method Details
-
save
Saves thisFileConfiguration
to the specified location.If the file does not exist, it will be created. If already exists, it will be overwritten. If it cannot be overwritten or created, an exception will be thrown.
This method will save using the system default encoding, or possibly using UTF8.
- Parameters:
file
- File to save to.- Throws:
IOException
- Thrown when the given file cannot be written to for any reason.IllegalArgumentException
- Thrown when file is null.
-
save
Saves thisFileConfiguration
to the specified location.If the file does not exist, it will be created. If already exists, it will be overwritten. If it cannot be overwritten or created, an exception will be thrown.
This method will save using the system default encoding, or possibly using UTF8.
- Parameters:
file
- File to save to.- Throws:
IOException
- Thrown when the given file cannot be written to for any reason.IllegalArgumentException
- Thrown when file is null.
-
saveToString
Saves thisFileConfiguration
to a string, and returns it.- Returns:
- String containing this configuration.
-
load
public void load(@NotNull @NotNull File file) throws FileNotFoundException, IOException, InvalidConfigurationException Loads thisFileConfiguration
from the specified location.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 file.
If the file cannot be loaded for any reason, an exception will be thrown.
- Parameters:
file
- File to load from.- Throws:
FileNotFoundException
- Thrown when the given file cannot be opened.IOException
- Thrown when the given file cannot be read.InvalidConfigurationException
- Thrown when the given file is not a valid Configuration.IllegalArgumentException
- Thrown when file is null.
-
load
Loads thisFileConfiguration
from the specified reader.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 stream.
- Parameters:
reader
- the reader to load from- Throws:
IOException
- thrown when underlying reader throws an IOExceptionInvalidConfigurationException
- thrown when the reader does not represent a valid ConfigurationIllegalArgumentException
- thrown when reader is null
-
load
public void load(@NotNull @NotNull String file) throws FileNotFoundException, IOException, InvalidConfigurationException Loads thisFileConfiguration
from the specified location.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 file.
If the file cannot be loaded for any reason, an exception will be thrown.
- Parameters:
file
- File to load from.- Throws:
FileNotFoundException
- Thrown when the given file cannot be opened.IOException
- Thrown when the given file cannot be read.InvalidConfigurationException
- Thrown when the given file is not a valid Configuration.IllegalArgumentException
- Thrown when file is null.
-
loadFromString
public abstract void loadFromString(@NotNull @NotNull String contents) throws InvalidConfigurationException Loads thisFileConfiguration
from 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.
- Parameters:
contents
- Contents of a Configuration to load.- Throws:
InvalidConfigurationException
- Thrown if the specified string is invalid.IllegalArgumentException
- Thrown if contents is null.
-
buildHeader
Deprecated.This method only exists for backwards compatibility. It will do nothing and should not be used! Please useFileConfigurationOptions.getHeader()
instead.- Returns:
- empty string
-
options
Description copied from interface:Configuration
Gets theConfigurationOptions
for thisConfiguration
.All setters through this method are chainable.
- Specified by:
options
in interfaceConfiguration
- Overrides:
options
in classMemoryConfiguration
- Returns:
- Options for this configuration
-