Class DifficultyDependentNode<T>

Type Parameters:
T - The value type, shared between each sub-node.

public abstract class DifficultyDependentNode<T> extends ContainerNode
Represents a node which has a value dependent on difficulty.
Since:
1.9.1
Author:
Isabel Maskrey
  • Constructor Details

    • DifficultyDependentNode

      protected DifficultyDependentNode(@NotNull @NotNull ConfigurationNode<?> parent, @NotNull @NotNull String name)
      Initializes a new difficulty-dependent configuration node.
      Parameters:
      parent - The parent node.
      name - The node name.
      Since:
      1.9.1
  • Method Details

    • getPeacefulNode

      @Nullable protected @Nullable ConfigurationNode<T> getPeacefulNode()
      Gets the node instance for the peaceful difficulty value.
      Returns:
      The peaceful node.
      Since:
      1.9.1
    • getEasyNode

      @Nullable protected @Nullable ConfigurationNode<T> getEasyNode()
      Gets the node instance for the easy difficulty value.
      Returns:
      The easy node.
      Since:
      1.9.1
    • getNormalNode

      @Nullable protected @Nullable ConfigurationNode<T> getNormalNode()
      Gets the node instance for the normal difficulty value.
      Returns:
      The normal node.
      Since:
      1.9.1
    • getHardNode

      @Nullable protected @Nullable ConfigurationNode<T> getHardNode()
      Gets the node instance for the hard difficulty value.
      Returns:
      The hard node.
      Since:
      1.10.0
    • getValueNodeName

      @NotNull public final @NotNull String 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.

      Overrides:
      getValueNodeName in class ConfigurationNode<Void>
      Returns:
      The name of the value node.
      Since:
      1.10.0
    • value

      @Nullable public T value(@NotNull @NotNull org.bukkit.Difficulty difficulty)
      Gets a value specific to the given difficulty value.
      Parameters:
      difficulty - The difficulty of the current world.
      Returns:
      The value of the node for that difficulty.
      Since:
      1.10.0
    • setValue

      public final void setValue(@NotNull @NotNull org.bukkit.Difficulty difficulty, @Nullable T value)
      Sets the value of the node for a specific difficulty.
      Parameters:
      difficulty - The difficulty level.
      value - The value of the node at the difficulty level.
      Since:
      1.10.0
    • save

      public void save()
      Writes the value of the node and its children to the config file.
      Overrides:
      save in class ContainerNode
      Since:
      1.10.0
    • getChildren

      @NotNull public @NotNull @Unmodifiable List<@NotNull ConfigurationNode<?>> getChildren()
      Gets an unmodifiable list of children for this node.
      Overrides:
      getChildren in class ConfigurationNode<Void>
      Returns:
      An unmodifiable list of the item's children.
      Since:
      1.10.0