Interface ConfigurationSection
- All Known Subinterfaces:
Configuration
- All Known Implementing Classes:
FileConfiguration
,MemoryConfiguration
,MemorySection
,YamlConfiguration
Configuration
-
Method Summary
Modifier and TypeMethodDescriptionvoid
addDefault
(@NotNull String path, @Nullable Object value) Sets the default value in the root at the given path as provided.boolean
Checks if thisConfigurationSection
contains the given path.boolean
Checks if thisConfigurationSection
contains the given path.createSection
(@NotNull String path) Creates an emptyConfigurationSection
at the specified path.createSection
(@NotNull String path, @NotNull Map<?, ?> map) Creates aConfigurationSection
at the specified path, with specified values.Gets the requested Object by path.Gets the requested Object by path, returning a default value if not found.boolean
getBoolean
(@NotNull String path) Gets the requested boolean by path.boolean
getBoolean
(@NotNull String path, boolean def) Gets the requested boolean by path, returning a default value if not found.getBooleanList
(@NotNull String path) Gets the requested List of Boolean by path.getByteList
(@NotNull String path) Gets the requested List of Byte by path.getCharacterList
(@NotNull String path) Gets the requested List of Character by path.Gets the requested Color by path.Gets the requestedColor
by path, returning a default value if not found.getComments
(@NotNull String path) Gets the requested comment list by path.default <C extends Component>
CgetComponent
(@NotNull String path, @NotNull ComponentDecoder<? super String, C> decoder) Gets the requested formatted String as Component by path deserialized by the ComponentDecoder.default <C extends Component>
CgetComponent
(@NotNull String path, @NotNull ComponentDecoder<? super String, C> decoder, C fallback) Gets the requested formatted String as Component by path deserialized by the ComponentDecoder.Gets the requested ConfigurationSection by path.Gets the path of thisConfigurationSection
from its rootConfiguration
double
Gets the requested double by path.double
Gets the requested double by path, returning a default value if not found.getDoubleList
(@NotNull String path) Gets the requested List of Double by path.getFloatList
(@NotNull String path) Gets the requested List of Float by path.getInlineComments
(@NotNull String path) Gets the requested inline comment list by path.int
Gets the requested int by path.int
Gets the requested int by path, returning a default value if not found.getIntegerList
(@NotNull String path) Gets the requested List of Integer by path.getItemStack
(@NotNull String path) Gets the requested ItemStack by path.getItemStack
(@NotNull String path, @Nullable ItemStack def) Gets the requestedItemStack
by path, returning a default value if not found.getKeys
(boolean deep) Gets a set containing all keys in this section.Gets the requested List by path.Gets the requested List by path, returning a default value if not found.getLocation
(@NotNull String path) Gets the requested Location by path.getLocation
(@NotNull String path, @Nullable Location def) Gets the requestedLocation
by path, returning a default value if not found.long
Gets the requested long by path.long
Gets the requested long by path, returning a default value if not found.getLongList
(@NotNull String path) Gets the requested List of Long by path.getMapList
(@NotNull String path) Gets the requested List of Maps by path.getName()
Gets the name of this individualConfigurationSection
, in the path.<T> T
Gets the requested object at the given path.<T> T
Gets the requested object at the given path, returning a default value if not found If the Object does not exist then the specified default value will returned regardless of if a default has been identified in the rootConfiguration
.getOfflinePlayer
(@NotNull String path) Gets the requested OfflinePlayer by path.getOfflinePlayer
(@NotNull String path, @Nullable OfflinePlayer def) Gets the requestedOfflinePlayer
by path, returning a default value if not found.Gets the parentConfigurationSection
that directly contains thisConfigurationSection
.getRichMessage
(@NotNull String path) Gets the requested MiniMessage formatted String as Component by path.getRichMessage
(@NotNull String path, @Nullable Component fallback) Gets the requested MiniMessage formatted String as Component by path.getRoot()
Gets the rootConfiguration
that contains thisConfigurationSection
<T extends ConfigurationSerializable>
TgetSerializable
(@NotNull String path, @NotNull Class<T> clazz) Gets the requestedConfigurationSerializable
object at the given path.<T extends ConfigurationSerializable>
TgetSerializable
(@NotNull String path, @NotNull Class<T> clazz, T def) Gets the requestedConfigurationSerializable
object at the given path, returning a default value if not found If the Object does not exist then the specified default value will returned regardless of if a default has been identified in the rootConfiguration
.getShortList
(@NotNull String path) Gets the requested List of Short by path.Gets the requested String by path.Gets the requested String by path, returning a default value if not found.getStringList
(@NotNull String path) Gets the requested List of String by path.getValues
(boolean deep) Gets a Map containing all keys and their values for this section.Gets the requested Vector by path.Gets the requestedVector
by path, returning a default value if not found.boolean
Checks if the specified path is a boolean.boolean
Checks if the specified path is a Color.boolean
Checks if the specified path is a ConfigurationSection.boolean
Checks if the specified path is a double.boolean
Checks if the specified path is an int.boolean
isItemStack
(@NotNull String path) Checks if the specified path is an ItemStack.boolean
Checks if the specified path is a List.boolean
isLocation
(@NotNull String path) Checks if the specified path is a Location.boolean
Checks if the specified path is a long.boolean
isOfflinePlayer
(@NotNull String path) Checks if the specified path is an OfflinePlayer.boolean
Checks if thisConfigurationSection
has a value set for the given path.boolean
Checks if the specified path is a String.boolean
Checks if the specified path is a Vector.void
Sets the specified path to the given value.void
Sets the comment list at the specified path.default <C extends Component>
voidsetComponent
(@NotNull String path, @NotNull ComponentEncoder<C, String> encoder, C value) Sets the specified path to the given value.void
Sets the inline comment list at the specified path.default void
setRichMessage
(@NotNull String path, @Nullable Component value) Sets the specified path to the given value.
-
Method Details
-
getKeys
Gets a set containing all keys in this section.If deep is set to true, then this will contain all the keys within any child
ConfigurationSection
s (and their children, etc). These will be in a valid path notation for you to use.If deep is set to false, then this will contain only the keys of any direct children, and not their own children.
- Parameters:
deep
- Whether or not to get a deep list, as opposed to a shallow list.- Returns:
- Set of keys contained within this ConfigurationSection.
-
getValues
Gets a Map containing all keys and their values for this section.If deep is set to true, then this will contain all the keys and values within any child
ConfigurationSection
s (and their children, etc). These keys will be in a valid path notation for you to use.If deep is set to false, then this will contain only the keys and values of any direct children, and not their own children.
- Parameters:
deep
- Whether or not to get a deep list, as opposed to a shallow list.- Returns:
- Map of keys and values of this section.
-
contains
Checks if thisConfigurationSection
contains the given path.If the value for the requested path does not exist but a default value has been specified, this will return true.
- Parameters:
path
- Path to check for existence.- Returns:
- True if this section contains the requested path, either via default or being set.
- Throws:
IllegalArgumentException
- Thrown when path is null.
-
contains
Checks if thisConfigurationSection
contains the given path.If the value for the requested path does not exist, the boolean parameter of true has been specified, a default value for the path exists, this will return true.
If a boolean parameter of false has been specified, true will only be returned if there is a set value for the specified path.
- Parameters:
path
- Path to check for existence.ignoreDefault
- Whether or not to ignore if a default value for the specified path exists.- Returns:
- True if this section contains the requested path, or if a default value exist and the boolean parameter for this method is true.
- Throws:
IllegalArgumentException
- Thrown when path is null.
-
isSet
Checks if thisConfigurationSection
has a value set for the given path.If the value for the requested path does not exist but a default value has been specified, this will still return false.
- Parameters:
path
- Path to check for existence.- Returns:
- True if this section contains the requested path, regardless of having a default.
- Throws:
IllegalArgumentException
- Thrown when path is null.
-
getCurrentPath
Gets the path of thisConfigurationSection
from its rootConfiguration
For any
Configuration
themselves, this will return an empty string.If the section is no longer contained within its root for any reason, such as being replaced with a different value, this may return null.
To retrieve the single name of this section, that is, the final part of the path returned by this method, you may use
getName()
.- Returns:
- Path of this section relative to its root
-
getName
Gets the name of this individualConfigurationSection
, in the path.This will always be the final part of
getCurrentPath()
, unless the section is orphaned.- Returns:
- Name of this section
-
getRoot
Gets the rootConfiguration
that contains thisConfigurationSection
For any
Configuration
themselves, this will return its own object.If the section is no longer contained within its root for any reason, such as being replaced with a different value, this may return null.
- Returns:
- Root configuration containing this section.
-
getParent
Gets the parentConfigurationSection
that directly contains thisConfigurationSection
.For any
Configuration
themselves, this will return null.If the section is no longer contained within its parent for any reason, such as being replaced with a different value, this may return null.
- Returns:
- Parent section containing this section.
-
get
Gets the requested Object by path.If the Object does not exist but a default value has been specified, this will return the default value. If the Object does not exist and no default value was specified, this will return null.
- Parameters:
path
- Path of the Object to get.- Returns:
- Requested Object.
-
get
@Contract("_, !null -> !null") @Nullable @Nullable Object get(@NotNull @NotNull String path, @Nullable @Nullable Object def) Gets the requested Object by path, returning a default value if not found.If the Object does not exist then the specified default value will returned regardless of if a default has been identified in the root
Configuration
.- Parameters:
path
- Path of the Object to get.def
- The default value to return if the path is not found.- Returns:
- Requested Object.
-
set
Sets the specified path to the given value.If value is null, the entry will be removed. Any existing entry will be replaced, regardless of what the new value is.
Some implementations may have limitations on what you may store. See their individual javadocs for details. No implementations should allow you to store
Configuration
s orConfigurationSection
s, please usecreateSection(java.lang.String)
for that.- Parameters:
path
- Path of the object to set.value
- New value to set the path to.
-
createSection
Creates an emptyConfigurationSection
at the specified path.Any value that was previously set at this path will be overwritten. If the previous value was itself a
ConfigurationSection
, it will be orphaned.- Parameters:
path
- Path to create the section at.- Returns:
- Newly created section
-
createSection
@NotNull @NotNull ConfigurationSection createSection(@NotNull @NotNull String path, @NotNull @NotNull Map<?, ?> map) Creates aConfigurationSection
at the specified path, with specified values.Any value that was previously set at this path will be overwritten. If the previous value was itself a
ConfigurationSection
, it will be orphaned.- Parameters:
path
- Path to create the section at.map
- The values to used.- Returns:
- Newly created section
-
getString
Gets the requested String by path.If the String does not exist but a default value has been specified, this will return the default value. If the String does not exist and no default value was specified, this will return null.
- Parameters:
path
- Path of the String to get.- Returns:
- Requested String.
-
getString
@Contract("_, !null -> !null") @Nullable @Nullable String getString(@NotNull @NotNull String path, @Nullable @Nullable String def) Gets the requested String by path, returning a default value if not found.If the String does not exist then the specified default value will returned regardless of if a default has been identified in the root
Configuration
.- Parameters:
path
- Path of the String to get.def
- The default value to return if the path is not found or is not a String.- Returns:
- Requested String.
-
isString
Checks if the specified path is a String.If the path exists but is not a String, this will return false. If the path does not exist, this will return false. If the path does not exist but a default value has been specified, this will check if that default value is a String and return appropriately.
- Parameters:
path
- Path of the String to check.- Returns:
- Whether or not the specified path is a String.
-
getInt
Gets the requested int by path.If the int does not exist but a default value has been specified, this will return the default value. If the int does not exist and no default value was specified, this will return 0.
- Parameters:
path
- Path of the int to get.- Returns:
- Requested int.
-
getInt
Gets the requested int by path, returning a default value if not found.If the int does not exist then the specified default value will returned regardless of if a default has been identified in the root
Configuration
.- Parameters:
path
- Path of the int to get.def
- The default value to return if the path is not found or is not an int.- Returns:
- Requested int.
-
isInt
Checks if the specified path is an int.If the path exists but is not a int, this will return false. If the path does not exist, this will return false. If the path does not exist but a default value has been specified, this will check if that default value is a int and return appropriately.
- Parameters:
path
- Path of the int to check.- Returns:
- Whether or not the specified path is an int.
-
getBoolean
Gets the requested boolean by path.If the boolean does not exist but a default value has been specified, this will return the default value. If the boolean does not exist and no default value was specified, this will return false.
- Parameters:
path
- Path of the boolean to get.- Returns:
- Requested boolean.
-
getBoolean
Gets the requested boolean by path, returning a default value if not found.If the boolean does not exist then the specified default value will returned regardless of if a default has been identified in the root
Configuration
.- Parameters:
path
- Path of the boolean to get.def
- The default value to return if the path is not found or is not a boolean.- Returns:
- Requested boolean.
-
isBoolean
Checks if the specified path is a boolean.If the path exists but is not a boolean, this will return false. If the path does not exist, this will return false. If the path does not exist but a default value has been specified, this will check if that default value is a boolean and return appropriately.
- Parameters:
path
- Path of the boolean to check.- Returns:
- Whether or not the specified path is a boolean.
-
getDouble
Gets the requested double by path.If the double does not exist but a default value has been specified, this will return the default value. If the double does not exist and no default value was specified, this will return 0.
- Parameters:
path
- Path of the double to get.- Returns:
- Requested double.
-
getDouble
Gets the requested double by path, returning a default value if not found.If the double does not exist then the specified default value will returned regardless of if a default has been identified in the root
Configuration
.- Parameters:
path
- Path of the double to get.def
- The default value to return if the path is not found or is not a double.- Returns:
- Requested double.
-
isDouble
Checks if the specified path is a double.If the path exists but is not a double, this will return false. If the path does not exist, this will return false. If the path does not exist but a default value has been specified, this will check if that default value is a double and return appropriately.
- Parameters:
path
- Path of the double to check.- Returns:
- Whether or not the specified path is a double.
-
getLong
Gets the requested long by path.If the long does not exist but a default value has been specified, this will return the default value. If the long does not exist and no default value was specified, this will return 0.
- Parameters:
path
- Path of the long to get.- Returns:
- Requested long.
-
getLong
Gets the requested long by path, returning a default value if not found.If the long does not exist then the specified default value will returned regardless of if a default has been identified in the root
Configuration
.- Parameters:
path
- Path of the long to get.def
- The default value to return if the path is not found or is not a long.- Returns:
- Requested long.
-
isLong
Checks if the specified path is a long.If the path exists but is not a long, this will return false. If the path does not exist, this will return false. If the path does not exist but a default value has been specified, this will check if that default value is a long and return appropriately.
- Parameters:
path
- Path of the long to check.- Returns:
- Whether or not the specified path is a long.
-
getList
Gets the requested List by path.If the List does not exist but a default value has been specified, this will return the default value. If the List does not exist and no default value was specified, this will return null.
- Parameters:
path
- Path of the List to get.- Returns:
- Requested List.
-
getList
@Contract("_, !null -> !null") @Nullable @Nullable List<?> getList(@NotNull @NotNull String path, @Nullable @Nullable List<?> def) Gets the requested List by path, returning a default value if not found.If the List does not exist then the specified default value will returned regardless of if a default has been identified in the root
Configuration
.- Parameters:
path
- Path of the List to get.def
- The default value to return if the path is not found or is not a List.- Returns:
- Requested List.
-
isList
Checks if the specified path is a List.If the path exists but is not a List, this will return false. If the path does not exist, this will return false. If the path does not exist but a default value has been specified, this will check if that default value is a List and return appropriately.
- Parameters:
path
- Path of the List to check.- Returns:
- Whether or not the specified path is a List.
-
getStringList
Gets the requested List of String by path.If the List does not exist but a default value has been specified, this will return the default value. If the List does not exist and no default value was specified, this will return an empty List.
This method will attempt to cast any values into a String if possible, but may miss any values out if they are not compatible.
- Parameters:
path
- Path of the List to get.- Returns:
- Requested List of String.
-
getIntegerList
Gets the requested List of Integer by path.If the List does not exist but a default value has been specified, this will return the default value. If the List does not exist and no default value was specified, this will return an empty List.
This method will attempt to cast any values into a Integer if possible, but may miss any values out if they are not compatible.
- Parameters:
path
- Path of the List to get.- Returns:
- Requested List of Integer.
-
getBooleanList
Gets the requested List of Boolean by path.If the List does not exist but a default value has been specified, this will return the default value. If the List does not exist and no default value was specified, this will return an empty List.
This method will attempt to cast any values into a Boolean if possible, but may miss any values out if they are not compatible.
- Parameters:
path
- Path of the List to get.- Returns:
- Requested List of Boolean.
-
getDoubleList
Gets the requested List of Double by path.If the List does not exist but a default value has been specified, this will return the default value. If the List does not exist and no default value was specified, this will return an empty List.
This method will attempt to cast any values into a Double if possible, but may miss any values out if they are not compatible.
- Parameters:
path
- Path of the List to get.- Returns:
- Requested List of Double.
-
getFloatList
Gets the requested List of Float by path.If the List does not exist but a default value has been specified, this will return the default value. If the List does not exist and no default value was specified, this will return an empty List.
This method will attempt to cast any values into a Float if possible, but may miss any values out if they are not compatible.
- Parameters:
path
- Path of the List to get.- Returns:
- Requested List of Float.
-
getLongList
Gets the requested List of Long by path.If the List does not exist but a default value has been specified, this will return the default value. If the List does not exist and no default value was specified, this will return an empty List.
This method will attempt to cast any values into a Long if possible, but may miss any values out if they are not compatible.
- Parameters:
path
- Path of the List to get.- Returns:
- Requested List of Long.
-
getByteList
Gets the requested List of Byte by path.If the List does not exist but a default value has been specified, this will return the default value. If the List does not exist and no default value was specified, this will return an empty List.
This method will attempt to cast any values into a Byte if possible, but may miss any values out if they are not compatible.
- Parameters:
path
- Path of the List to get.- Returns:
- Requested List of Byte.
-
getCharacterList
Gets the requested List of Character by path.If the List does not exist but a default value has been specified, this will return the default value. If the List does not exist and no default value was specified, this will return an empty List.
This method will attempt to cast any values into a Character if possible, but may miss any values out if they are not compatible.
- Parameters:
path
- Path of the List to get.- Returns:
- Requested List of Character.
-
getShortList
Gets the requested List of Short by path.If the List does not exist but a default value has been specified, this will return the default value. If the List does not exist and no default value was specified, this will return an empty List.
This method will attempt to cast any values into a Short if possible, but may miss any values out if they are not compatible.
- Parameters:
path
- Path of the List to get.- Returns:
- Requested List of Short.
-
getMapList
Gets the requested List of Maps by path.If the List does not exist but a default value has been specified, this will return the default value. If the List does not exist and no default value was specified, this will return an empty List.
This method will attempt to cast any values into a Map if possible, but may miss any values out if they are not compatible.
- Parameters:
path
- Path of the List to get.- Returns:
- Requested List of Maps.
-
getObject
Gets the requested object at the given path. If the Object does not exist but a default value has been specified, this will return the default value. If the Object does not exist and no default value was specified, this will return null. Note: For example #getObject(path, String.class) is not equivalent to#getString(path)
because#getString(path)
converts internally all Objects to Strings. However, #getObject(path, Boolean.class) is equivalent to#getBoolean(path)
for example.- Type Parameters:
T
- the type of the requested object- Parameters:
path
- the path to the object.clazz
- the type of the requested object- Returns:
- Requested object
-
getObject
@Contract("_, _, !null -> !null") @Nullable <T> T getObject(@NotNull @NotNull String path, @NotNull @NotNull Class<T> clazz, @Nullable T def) Gets the requested object at the given path, returning a default value if not found If the Object does not exist then the specified default value will returned regardless of if a default has been identified in the rootConfiguration
. Note: For example #getObject(path, String.class, def) is not equivalent to#getString(path, def)
because#getString(path, def)
converts internally all Objects to Strings. However, #getObject(path, Boolean.class, def) is equivalent to#getBoolean(path, def)
for example.- Type Parameters:
T
- the type of the requested object- Parameters:
path
- the path to the object.clazz
- the type of the requested objectdef
- the default object to return if the object is not present at the path- Returns:
- Requested object
-
getSerializable
@Nullable <T extends ConfigurationSerializable> T getSerializable(@NotNull @NotNull String path, @NotNull @NotNull Class<T> clazz) Gets the requestedConfigurationSerializable
object at the given path. If the Object does not exist but a default value has been specified, this will return the default value. If the Object does not exist and no default value was specified, this will return null.- Type Parameters:
T
- the type ofConfigurationSerializable
- Parameters:
path
- the path to the object.clazz
- the type ofConfigurationSerializable
- Returns:
- Requested
ConfigurationSerializable
object
-
getSerializable
@Contract("_, _, !null -> !null") @Nullable <T extends ConfigurationSerializable> T getSerializable(@NotNull @NotNull String path, @NotNull @NotNull Class<T> clazz, @Nullable T def) Gets the requestedConfigurationSerializable
object at the given path, returning a default value if not found If the Object does not exist then the specified default value will returned regardless of if a default has been identified in the rootConfiguration
.- Type Parameters:
T
- the type ofConfigurationSerializable
- Parameters:
path
- the path to the object.clazz
- the type ofConfigurationSerializable
def
- the default object to return if the object is not present at the path- Returns:
- Requested
ConfigurationSerializable
object
-
getVector
Gets the requested Vector by path.If the Vector does not exist but a default value has been specified, this will return the default value. If the Vector does not exist and no default value was specified, this will return null.
- Parameters:
path
- Path of the Vector to get.- Returns:
- Requested Vector.
-
getVector
@Contract("_, !null -> !null") @Nullable @Nullable Vector getVector(@NotNull @NotNull String path, @Nullable @Nullable Vector def) Gets the requestedVector
by path, returning a default value if not found.If the Vector does not exist then the specified default value will returned regardless of if a default has been identified in the root
Configuration
.- Parameters:
path
- Path of the Vector to get.def
- The default value to return if the path is not found or is not a Vector.- Returns:
- Requested Vector.
-
isVector
Checks if the specified path is a Vector.If the path exists but is not a Vector, this will return false. If the path does not exist, this will return false. If the path does not exist but a default value has been specified, this will check if that default value is a Vector and return appropriately.
- Parameters:
path
- Path of the Vector to check.- Returns:
- Whether or not the specified path is a Vector.
-
getOfflinePlayer
Gets the requested OfflinePlayer by path.If the OfflinePlayer does not exist but a default value has been specified, this will return the default value. If the OfflinePlayer does not exist and no default value was specified, this will return null.
- Parameters:
path
- Path of the OfflinePlayer to get.- Returns:
- Requested OfflinePlayer.
-
getOfflinePlayer
@Contract("_, !null -> !null") @Nullable @Nullable OfflinePlayer getOfflinePlayer(@NotNull @NotNull String path, @Nullable @Nullable OfflinePlayer def) Gets the requestedOfflinePlayer
by path, returning a default value if not found.If the OfflinePlayer does not exist then the specified default value will returned regardless of if a default has been identified in the root
Configuration
.- Parameters:
path
- Path of the OfflinePlayer to get.def
- The default value to return if the path is not found or is not an OfflinePlayer.- Returns:
- Requested OfflinePlayer.
-
isOfflinePlayer
Checks if the specified path is an OfflinePlayer.If the path exists but is not a OfflinePlayer, this will return false. If the path does not exist, this will return false. If the path does not exist but a default value has been specified, this will check if that default value is a OfflinePlayer and return appropriately.
- Parameters:
path
- Path of the OfflinePlayer to check.- Returns:
- Whether or not the specified path is an OfflinePlayer.
-
getItemStack
Gets the requested ItemStack by path.If the ItemStack does not exist but a default value has been specified, this will return the default value. If the ItemStack does not exist and no default value was specified, this will return null.
- Parameters:
path
- Path of the ItemStack to get.- Returns:
- Requested ItemStack.
-
getItemStack
@Contract("_, !null -> !null") @Nullable @Nullable ItemStack getItemStack(@NotNull @NotNull String path, @Nullable @Nullable ItemStack def) Gets the requestedItemStack
by path, returning a default value if not found.If the ItemStack does not exist then the specified default value will returned regardless of if a default has been identified in the root
Configuration
.- Parameters:
path
- Path of the ItemStack to get.def
- The default value to return if the path is not found or is not an ItemStack.- Returns:
- Requested ItemStack.
-
isItemStack
Checks if the specified path is an ItemStack.If the path exists but is not a ItemStack, this will return false. If the path does not exist, this will return false. If the path does not exist but a default value has been specified, this will check if that default value is a ItemStack and return appropriately.
- Parameters:
path
- Path of the ItemStack to check.- Returns:
- Whether or not the specified path is an ItemStack.
-
getColor
Gets the requested Color by path.If the Color does not exist but a default value has been specified, this will return the default value. If the Color does not exist and no default value was specified, this will return null.
- Parameters:
path
- Path of the Color to get.- Returns:
- Requested Color.
-
getColor
@Contract("_, !null -> !null") @Nullable @Nullable Color getColor(@NotNull @NotNull String path, @Nullable @Nullable Color def) Gets the requestedColor
by path, returning a default value if not found.If the Color does not exist then the specified default value will returned regardless of if a default has been identified in the root
Configuration
.- Parameters:
path
- Path of the Color to get.def
- The default value to return if the path is not found or is not a Color.- Returns:
- Requested Color.
-
isColor
Checks if the specified path is a Color.If the path exists but is not a Color, this will return false. If the path does not exist, this will return false. If the path does not exist but a default value has been specified, this will check if that default value is a Color and return appropriately.
- Parameters:
path
- Path of the Color to check.- Returns:
- Whether or not the specified path is a Color.
-
getLocation
Gets the requested Location by path.If the Location does not exist but a default value has been specified, this will return the default value. If the Location does not exist and no default value was specified, this will return null.
- Parameters:
path
- Path of the Location to get.- Returns:
- Requested Location.
-
getLocation
@Contract("_, !null -> !null") @Nullable @Nullable Location getLocation(@NotNull @NotNull String path, @Nullable @Nullable Location def) Gets the requestedLocation
by path, returning a default value if not found.If the Location does not exist then the specified default value will returned regardless of if a default has been identified in the root
Configuration
.- Parameters:
path
- Path of the Location to get.def
- The default value to return if the path is not found or is not a Location.- Returns:
- Requested Location.
-
isLocation
Checks if the specified path is a Location.If the path exists but is not a Location, this will return false. If the path does not exist, this will return false. If the path does not exist but a default value has been specified, this will check if that default value is a Location and return appropriately.
- Parameters:
path
- Path of the Location to check.- Returns:
- Whether or not the specified path is a Location.
-
getConfigurationSection
Gets the requested ConfigurationSection by path.If the ConfigurationSection does not exist but a default value has been specified, this will return the default value. If the ConfigurationSection does not exist and no default value was specified, this will return null.
- Parameters:
path
- Path of the ConfigurationSection to get.- Returns:
- Requested ConfigurationSection.
-
isConfigurationSection
Checks if the specified path is a ConfigurationSection.If the path exists but is not a ConfigurationSection, this will return false. If the path does not exist, this will return false. If the path does not exist but a default value has been specified, this will check if that default value is a ConfigurationSection and return appropriately.
- Parameters:
path
- Path of the ConfigurationSection to check.- Returns:
- Whether or not the specified path is a ConfigurationSection.
-
getDefaultSection
Gets the equivalentConfigurationSection
from the defaultConfiguration
defined ingetRoot()
.If the root contains no defaults, or the defaults doesn't contain a value for this path, or the value at this path is not a
ConfigurationSection
then this will return null.- Returns:
- Equivalent section in root configuration
-
addDefault
Sets the default value in the root at the given path as provided.If no source
Configuration
was provided as a default collection, then a newMemoryConfiguration
will be created to hold the new default value.If value is null, the value will be removed from the default Configuration source.
If the value as returned by
getDefaultSection()
is null, then this will create a new section at the path, replacing anything that may have existed there previously.- Parameters:
path
- Path of the value to set.value
- Value to set the default to.- Throws:
IllegalArgumentException
- Thrown if path is null.
-
getComments
Gets the requested comment list by path.If no comments exist, an empty list will be returned. A null entry represents an empty line and an empty String represents an empty comment line.
- Parameters:
path
- Path of the comments to get.- Returns:
- A unmodifiable list of the requested comments, every entry represents one line.
-
getInlineComments
Gets the requested inline comment list by path.If no comments exist, an empty list will be returned. A null entry represents an empty line and an empty String represents an empty comment line.
- Parameters:
path
- Path of the comments to get.- Returns:
- A unmodifiable list of the requested comments, every entry represents one line.
-
setComments
Sets the comment list at the specified path.If value is null, the comments will be removed. A null entry is an empty line and an empty String entry is an empty comment line. If the path does not exist, no comments will be set. Any existing comments will be replaced, regardless of what the new comments are.
Some implementations may have limitations on what persists. See their individual javadocs for details.
- Parameters:
path
- Path of the comments to set.comments
- New comments to set at the path, every entry represents one line.
-
setInlineComments
Sets the inline comment list at the specified path.If value is null, the comments will be removed. A null entry is an empty line and an empty String entry is an empty comment line. If the path does not exist, no comment will be set. Any existing comments will be replaced, regardless of what the new comments are.
Some implementations may have limitations on what persists. See their individual javadocs for details.
- Parameters:
path
- Path of the comments to set.comments
- New comments to set at the path, every entry represents one line.
-
getRichMessage
Gets the requested MiniMessage formatted String as Component by path.If the Component does not exist but a default value has been specified, this will return the default value. If the Component does not exist and no default value was specified, this will return null.
- Parameters:
path
- Path of the Component to get.- Returns:
- Requested Component.
-
getRichMessage
@Contract("_, !null -> !null") default @Nullable Component getRichMessage(@NotNull @NotNull String path, @Nullable Component fallback) Gets the requested MiniMessage formatted String as Component by path.If the Component does not exist but a default value has been specified, this will return the default value. If the Component does not exist and no default value was specified, this will return null.
- Parameters:
path
- Path of the Component to get.fallback
- component that will be used as fallback- Returns:
- Requested Component.
-
setRichMessage
Sets the specified path to the given value.If value is null, the entry will be removed. Any existing entry will be replaced, regardless of what the new value is.
- Parameters:
path
- Path of the object to set.value
- New value to set the path to.
-
getComponent
@Nullable default <C extends Component> C getComponent(@NotNull @NotNull String path, @NotNull ComponentDecoder<? super String, C> decoder) Gets the requested formatted String as Component by path deserialized by the ComponentDecoder.If the Component does not exist but a default value has been specified, this will return the default value. If the Component does not exist and no default value was specified, this will return null.
- Parameters:
path
- Path of the Component to get.decoder
- ComponentDecoder instance used for deserialization- Returns:
- Requested Component.
-
getComponent
@Contract("_, _, !null -> !null") @Nullable default <C extends Component> C getComponent(@NotNull @NotNull String path, @NotNull ComponentDecoder<? super String, C> decoder, @Nullable C fallback) Gets the requested formatted String as Component by path deserialized by the ComponentDecoder.If the Component does not exist but a default value has been specified, this will return the default value. If the Component does not exist and no default value was specified, this will return null.
- Parameters:
path
- Path of the Component to get.decoder
- ComponentDecoder instance used for deserializationfallback
- component that will be used as fallback- Returns:
- Requested Component.
-
setComponent
default <C extends Component> void setComponent(@NotNull @NotNull String path, @NotNull ComponentEncoder<C, String> encoder, @Nullable C value) Sets the specified path to the given value.If value is null, the entry will be removed. Any existing entry will be replaced, regardless of what the new value is.
- Parameters:
path
- Path of the object to set.encoder
- the encoder used to transform the valuevalue
- New value to set the path to.
-