Package valorless.valorlessutils.file
Class YamlFile
java.lang.Object
org.bukkit.configuration.MemorySection
org.bukkit.configuration.MemoryConfiguration
org.bukkit.configuration.file.FileConfiguration
org.bukkit.configuration.file.YamlConfiguration
valorless.valorlessutils.file.FileStorage
valorless.valorlessutils.file.YamlFile
- All Implemented Interfaces:
org.bukkit.configuration.Configuration
,org.bukkit.configuration.ConfigurationSection
-
Field Summary
Fields inherited from class org.bukkit.configuration.file.YamlConfiguration
BLANK_CONFIG, COMMENT_PREFIX
Fields inherited from class org.bukkit.configuration.MemoryConfiguration
defaults, options
Fields inherited from class org.bukkit.configuration.MemorySection
map
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionboolean
Checks if the YamlConfiguration contains a value at the specified path.Gets a value from the YamlConfiguration.<T> T
Gets a typed value from the YamlConfiguration.org.bukkit.configuration.file.YamlConfiguration
Gets the underlying YamlConfiguration.<T> T
getOrDefault
(String path, T defaultValue) Gets a value from the YamlConfiguration or a default value if the path does not exist.org.bukkit.configuration.ConfigurationSection
getSection
(String path) Gets a ConfigurationSection from the YamlConfiguration.void
reload()
Reloads the YamlConfiguration from the associated file.boolean
save()
Saves the YamlConfiguration to the associated file.void
Sets a value in the YamlConfiguration.void
Sets a value in the YamlConfiguration only if the path does not already exist.Methods inherited from class valorless.valorlessutils.file.FileStorage
createFile, deleteFile, fileExists, getFile, loadConfiguration
Methods inherited from class org.bukkit.configuration.file.YamlConfiguration
loadConfiguration, loadFromString, options, saveToString
Methods inherited from class org.bukkit.configuration.file.FileConfiguration
buildHeader, load, load, load, save, save
Methods inherited from class org.bukkit.configuration.MemoryConfiguration
addDefault, addDefaults, addDefaults, getDefaults, getParent, setDefaults
Methods inherited from class org.bukkit.configuration.MemorySection
contains, createPath, createPath, createSection, createSection, 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, 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, createSection, createSection, get, getBoolean, getBoolean, getBooleanList, getByteList, getCharacterList, getColor, getColor, getComments, 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, getRoot, getSerializable, getSerializable, getShortList, getString, getString, getStringList, getValues, getVector, getVector, isBoolean, isColor, isConfigurationSection, isDouble, isInt, isItemStack, isList, isLocation, isLong, isOfflinePlayer, isSet, isString, isVector, setComments, setInlineComments
-
Constructor Details
-
YamlFile
Constructor for YamlFile class using a file path.- Parameters:
file
- The file path as a string.
-
YamlFile
Constructor for YamlFile class using a File object.- Parameters:
file
- The File object representing the YAML file.
-
-
Method Details
-
reload
public void reload()Reloads the YamlConfiguration from the associated file. -
set
Sets a value in the YamlConfiguration.- Specified by:
set
in interfaceorg.bukkit.configuration.ConfigurationSection
- Overrides:
set
in classorg.bukkit.configuration.MemorySection
- Parameters:
path
- The path to the value.value
- The value to set.
-
get
Gets a value from the YamlConfiguration.- Specified by:
get
in interfaceorg.bukkit.configuration.ConfigurationSection
- Overrides:
get
in classorg.bukkit.configuration.MemorySection
- Parameters:
path
- The path to the value.- Returns:
- The value at the specified path.
-
get
Gets a typed value from the YamlConfiguration.- Type Parameters:
T
- The type of the value.- Parameters:
path
- The path to the value.clazz
- The class of the value.- Returns:
- The typed value at the specified path.
-
contains
Checks if the YamlConfiguration contains a value at the specified path.- Specified by:
contains
in interfaceorg.bukkit.configuration.ConfigurationSection
- Overrides:
contains
in classorg.bukkit.configuration.MemorySection
- Parameters:
path
- The path to check.- Returns:
- true if the path exists, false otherwise.
-
setIfNull
Sets a value in the YamlConfiguration only if the path does not already exist.- Parameters:
path
- The path to the value.value
- The value to set.
-
getOrDefault
Gets a value from the YamlConfiguration or a default value if the path does not exist.- Type Parameters:
T
- The type of the value.- Parameters:
path
- The path to the value.defaultValue
- The default value to return if the path does not exist.- Returns:
- The value at the specified path or the default value if the path does not exist.
-
getSection
Gets a ConfigurationSection from the YamlConfiguration.- Parameters:
path
- The path to the ConfigurationSection.- Returns:
- The ConfigurationSection at the specified path.
-
save
public boolean save()Saves the YamlConfiguration to the associated file.- Returns:
- true if the save is successful, false otherwise.
-
getConfig
public org.bukkit.configuration.file.YamlConfiguration getConfig()Gets the underlying YamlConfiguration.- Returns:
- The YamlConfiguration instance.
-