Interface DataNode


public interface DataNode
Platform-independent tree of saved values (the content of one player data record).

Paths use . as separator ("armor_contents.helmet"). Values are plain YAML/JSON types: String, Number, Boolean, List and nested nodes. On Bukkit, item stacks saved by the plugin keep the Bukkit serialization format; on Fabric items are stored as SNBT strings (see PlayerSnapshot.format()).

  • Method Details

    • create

      @NotNull static @NotNull DataNode create()
      Returns:
      a new, empty, mutable node
    • of

      @NotNull static @NotNull DataNode of(@NotNull @NotNull Map<?,?> values)
      Returns:
      a new mutable node containing a deep copy of the given map
    • contains

      boolean contains(@NotNull @NotNull String path)
    • get

      @Nullable @Nullable Object get(@NotNull @NotNull String path)
      Returns:
      the raw value (nested nodes are returned as DataNode), or null
    • set

      void set(@NotNull @NotNull String path, @Nullable @Nullable Object value)
    • remove

      default void remove(@NotNull @NotNull String path)
    • keys

      @NotNull @NotNull Set<String> keys()
      Returns:
      the direct child keys of this node, in insertion order
    • getNode

      @Nullable @Nullable DataNode getNode(@NotNull @NotNull String path)
      Returns:
      the child node at the path, or null when absent or not a node
    • getOrCreateNode

      @NotNull @NotNull DataNode getOrCreateNode(@NotNull @NotNull String path)
      Returns:
      the child node at the path, creating it (and replacing any non-node value) when needed
    • getString

      @Nullable default @Nullable String getString(@NotNull @NotNull String path)
    • getString

      @NotNull default @NotNull String getString(@NotNull @NotNull String path, @NotNull @NotNull String def)
    • getInt

      default int getInt(@NotNull @NotNull String path, int def)
    • getLong

      default long getLong(@NotNull @NotNull String path, long def)
    • getDouble

      default double getDouble(@NotNull @NotNull String path, double def)
    • getFloat

      default float getFloat(@NotNull @NotNull String path, float def)
    • getBoolean

      default boolean getBoolean(@NotNull @NotNull String path, boolean def)
    • getList

      @Nullable default @Nullable List<?> getList(@NotNull @NotNull String path)
    • toMap

      @NotNull @NotNull Map<String,Object> toMap()
      Returns:
      a deep copy of this node as nested Map<String, Object> (ready for YAML/JSON)
    • copy

      @NotNull default @NotNull DataNode copy()
      Returns:
      a deep, independent copy of this node
    • number

      @Nullable static @Nullable Number number(@Nullable @Nullable Object v)