Class ConfigurationNode<T>
- Type Parameters:
T
- The value type.
- Direct Known Subclasses:
BigDecimalNode
,BigIntegerNode
,BooleanNode
,ConfigurationContainer
,ContainerNode
,DifficultyDependentNode
,DoubleNode
,EnumListNode
,EnumNode
,IntegerNode
,MapListNode
,OptionalConfigurationNode
,StringNode
,TypedMapListNode
- Since:
- 1.0.0
- Author:
- Isabel Maskrey
-
Constructor Summary
ModifierConstructorDescriptionprotected
ConfigurationNode
(@NotNull ConfigurationNode<?> parent, @Nullable String name) Initializes a new Configuration node.protected
ConfigurationNode
(@NotNull ConfigurationNode<?> parent, @Nullable String name, @NotNull org.bukkit.configuration.Configuration config) Deprecated, for removal: This API element is subject to removal in a future version.Since 1.9.0.protected
ConfigurationNode
(@NotNull org.bukkit.plugin.Plugin plugin, @Nullable ConfigurationNode<?> parent, @Nullable String name) Initializes a new Configuration node.protected
ConfigurationNode
(@NotNull org.bukkit.plugin.Plugin plugin, @Nullable ConfigurationNode<?> parent, @Nullable String name, @NotNull org.bukkit.configuration.Configuration config) Deprecated, for removal: This API element is subject to removal in a future version.Since 1.9.0. -
Method Summary
Modifier and TypeMethodDescriptionprotected final void
addChild
(@NotNull ConfigurationNode<?> configurationNode) Ensures that the node's list of children includes the specified child node.abstract T
Gets the default value of the node.boolean
Indicates whether some other object is "equal to" this one.final @NotNull String
Gets the path of the base node.final @NotNull String
getBasePath
(@NotNull StringBuilder stringBuilder) Gets the path of the base node.@NotNull @Unmodifiable List<@NotNull ConfigurationNode<?>>
Gets an unmodifiable list of children for this node.Gets the comment list for the value node path.getComments
(boolean basePath) Gets the comment list for this node.@NotNull org.bukkit.configuration.Configuration
Gets the configuration instance for the plugin.Gets the inline comment list for the value node path.getInlineComments
(boolean basePath) Gets the inline comment list for this node.@NotNull Logger
Returns the plugin logger associated with this server's logger.@Nullable String
getName()
Gets the name of the node.@NotNull String
getPath()
Deprecated.Since 1.9.0.final @NotNull String
getPath
(@NotNull StringBuilder stringBuilder) Deprecated.Since 1.9.0.@NotNull org.bukkit.plugin.Plugin
Gets the plugin instance.@NotNull NodePriority
Gets the priority of this node.org.slf4j.Logger
Returns the plugin logger associated with this server's logger.@NotNull String
Gets the name of the value node, which will be used if this node contains children and a value.final @NotNull String
Gets the path of the node that contains the value.final @NotNull String
getValuePath
(@NotNull StringBuilder stringBuilder) Gets the path of the node that contains the value.final boolean
Whether the configuration node contains children.final boolean
hasName()
Whether the configuration node is named.final boolean
Whether the configuration node is a sub node or a root node.void
save()
Writes the value of the node to the config file.void
setComments
(boolean basePath, @Nullable String... comments) Sets the comment list for the node.void
setComments
(@Nullable String... comments) Sets the comment list at the value node path.void
setConfigValue
(T value) Sets the value of the node in the configuration file.void
setInlineComments
(boolean basePath, @Nullable String... comments) Sets the inline comment list for the node.void
setInlineComments
(@Nullable String... comments) Sets the inline comment list at the value node path.void
Deprecated, for removal: This API element is subject to removal in a future version.Since 1.10.0.final @NotNull String
toString()
Returns the string representation of this node.void
toString
(@NotNull StringBuilder stringBuilder) Builds the string value of the node.abstract T
value()
Gets the value of the node.
-
Constructor Details
-
ConfigurationNode
@Deprecated(since="1.9.0", forRemoval=true) protected ConfigurationNode(@NotNull @NotNull ConfigurationNode<?> parent, @Nullable @Nullable String name, @NotNull @NotNull org.bukkit.configuration.Configuration config) Deprecated, for removal: This API element is subject to removal in a future version.Since 1.9.0. Use a constructor which does not use aconfiguration
parameter, as the value of the parameter is ignored.Initializes a new Configuration node.- Parameters:
parent
- The parent node.name
- The node name.config
- The configuration instance.- Since:
- 1.0.0
-
ConfigurationNode
@Deprecated(since="1.9.0", forRemoval=true) protected ConfigurationNode(@NotNull @NotNull org.bukkit.plugin.Plugin plugin, @Nullable @Nullable ConfigurationNode<?> parent, @Nullable @Nullable String name, @NotNull @NotNull org.bukkit.configuration.Configuration config) Deprecated, for removal: This API element is subject to removal in a future version.Since 1.9.0. Use a constructor which does not use aconfiguration
parameter, as the value of the parameter is ignored.Initializes a new Configuration node.- Parameters:
plugin
- The plugin instance.parent
- The parent node.name
- The node name.config
- The configuration instance.- Since:
- 1.6.0
-
ConfigurationNode
protected ConfigurationNode(@NotNull @NotNull ConfigurationNode<?> parent, @Nullable @Nullable String name) Initializes a new Configuration node.- Parameters:
parent
- The parent node.name
- The node name.- Since:
- 1.0.0
-
ConfigurationNode
protected ConfigurationNode(@NotNull @NotNull org.bukkit.plugin.Plugin plugin, @Nullable @Nullable ConfigurationNode<?> parent, @Nullable @Nullable String name) Initializes a new Configuration node.- Parameters:
plugin
- The plugin instance.parent
- The parent node.name
- The node name.- Since:
- 1.6.0
-
-
Method Details
-
getPlugin
@NotNull public @NotNull org.bukkit.plugin.Plugin getPlugin()Gets the plugin instance.- Returns:
- The plugin instance.
- Since:
- 1.6.0
-
getConfig
@NotNull public @NotNull org.bukkit.configuration.Configuration getConfig()Gets the configuration instance for the plugin.- Returns:
- The configuration instance.
- Since:
- 1.0.0
-
getName
Gets the name of the node.- Returns:
- The name of the node.
- Since:
- 1.0.0
-
getPath
Deprecated.Since 1.9.0. UsegetValuePath()
orgetBasePath(StringBuilder)
instead.Constructs the full node path.- Returns:
- The full node path.
- Since:
- 1.0.0
-
getPath
@Deprecated(since="1.9.0") @NotNull public final @NotNull String getPath(@NotNull @NotNull StringBuilder stringBuilder) Deprecated.Since 1.9.0. UsegetValuePath()
orgetBasePath(StringBuilder)
instead.Constructs the full node path.- Parameters:
stringBuilder
- TheStringBuilder
with which to build out the full node path.- Returns:
- The full node path.
- Since:
- 1.0.0
-
getValuePath
Gets the path of the node that contains the value.Only matches the value of
getBasePath(...)
if this node does not contain any children.- Returns:
- The full path of the node which contains the value.
- Since:
- 1.10.0
-
getValuePath
Gets the path of the node that contains the value.Only matches the value of
getBasePath(...)
if this node does not contain any children.- Parameters:
stringBuilder
- The string builder with which to build out the full path name.- Returns:
- The full path of the node which contains the value.
- Since:
- 1.9.0
-
getBasePath
Gets the path of the base node.Only matches the value of
getValuePath(...)
if this node does not contain any children.- Returns:
- The full path of this node.
- Since:
- 1.9.0
-
getBasePath
Gets the path of the base node.Only matches the value of
getValuePath(...)
if this node does not contain any children.- Parameters:
stringBuilder
- TheStringBuilder
with which to build out the full path name.- Returns:
- The full path of this node.
- Since:
- 1.9.0
-
getValueNodeName
Gets the name of the value node, which will be used if this node contains children and a value.Defaults to "value" for most node types.
- Returns:
- The name of the value node.
- Since:
- 1.9.0
-
toString
Returns the string representation of this node.By default, this matches the format
path=value
, wherepath
is the path of the configuration value, andvalue
is the string representation of the value of this node.This can be overridden indirectly by altering
toString(StringBuilder)
. -
toString
Builds the string value of the node.Override this to alter the value returned by
toString()
.By default, this matches the format
path=value
, wherepath
is the path of the configuration value, andvalue
is the string representation of the value of this node.- Parameters:
stringBuilder
- TheStringBuilder
with which to build the string.- Since:
- 1.9.1
-
value
Gets the value of the node.- Returns:
- The value.
- Since:
- 1.0.0
-
defaultValue
Gets the default value of the node.- Returns:
- The default value.
- Since:
- 1.3.0
-
setValue
Deprecated, for removal: This API element is subject to removal in a future version.Since 1.10.0. UsesetConfigValue(T)
instead. Will be removed in the future.Sets the value of the node in the configuration file.- Parameters:
value
- The value to set.- Since:
- 1.9.0
-
setConfigValue
Sets the value of the node in the configuration file.- Parameters:
value
- The value to set.- Since:
- 1.10.0
-
addChild
Ensures that the node's list of children includes the specified child node.Duplicated values are discarded.
- Parameters:
configurationNode
- the child to add to the node.- Since:
- 1.9.0
-
hasChildren
public final boolean hasChildren()Whether the configuration node contains children.- Returns:
true
if the child list is not empty; otherwise,false
- Since:
- 1.9.0
-
isSubNode
public final boolean isSubNode()Whether the configuration node is a sub node or a root node.- Returns:
true
if the node has a parent node; otherwise,false
- Since:
- 1.9.0
-
hasName
public final boolean hasName()Whether the configuration node is named.- Returns:
true
if the root node name is not null or blank; otherwise,false
- Since:
- 1.9.0
-
save
public void save()Writes the value of the node to the config file.- Since:
- 1.9.0
-
getComments
Gets the comment list for the value node 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.
- Returns:
- An unmodifiable list of the node's comments. Every entry represents one line.
- Since:
- 1.9.0
-
getComments
Gets the comment list for this node.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:
basePath
- Iftrue
, the node's base path will be used instead of its value path. This is useful if you have nested value nodes.- Returns:
- An unmodifiable list of the node's comments. Every entry represents one line.
- Since:
- 1.9.0
-
getInlineComments
Gets the inline comment list for the value node 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.
- Returns:
- An unmodifiable list of the node's inline comments. Every entry represents one line.
- Since:
- 1.9.0
-
getInlineComments
Gets the inline comment list for this node.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:
basePath
- Iftrue
, the node's base path will be used instead of the value path. This is useful if you have nested value nodes.- Returns:
- An unmodifiable list of the node's inline comments. Every entry represents one line.
- Since:
- 1.9.0
-
setComments
Sets the comment list at the value node 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:
comments
- New comments to set at the value node. Every entry represents a new line.- Since:
- 1.9.0
-
setComments
Sets the comment list for the node.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:
basePath
- Iftrue
, the node's base path will be used instead of its value path. This is useful if you have nested value nodes.comments
- New comments to set for the node. Every entry represents a new line.- Since:
- 1.9.0
-
setInlineComments
Sets the inline comment list at the value node 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:
comments
- New comments to set at the value node path. Every entry represents a new line.- Since:
- 1.9.0
-
setInlineComments
Sets the inline comment list for the node.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:
basePath
- iftrue
, the base path will be used instead of the value path. This can be useful if you have nested value nodes.comments
- New comments to set for the node. Every entry represents a new line.- Since:
- 1.9.0
-
getLogger
Returns the plugin logger associated with this server's logger. The returned logger automatically tags all log messages with the plugin's name.- Returns:
- Logger associated with this plugin
- Since:
- 1.9.0
-
getSLF4JLogger
@NotNull public org.slf4j.Logger getSLF4JLogger()Returns the plugin logger associated with this server's logger. The returned logger automatically tags all log messages with the plugin's name.- Returns:
- SLF4J Logger associated with the plugin.
- Since:
- 1.9.0
-
getChildren
Gets an unmodifiable list of children for this node.- Returns:
- An unmodifiable list of the item's children.
- Since:
- 1.9.1
-
equals
Indicates whether some other object is "equal to" this one.Two
ConfigurationNode
objects are equivalent based purely on whether their plugin instance and base path are the same. -
getPriority
Gets the priority of this node.See
NodePriority
for an explanation of priority functionality.- Returns:
- The node's priority.
-