Interface DataSection<P>

Type Parameters:
P - platform player type (org.bukkit.entity.Player or ServerPlayer)

public interface DataSection<P>
Extra player data that SepareWorldItems saves and restores per group, next to the built-in inventory/XP/health... Use it to keep your plugin's or mod's own state separated per world group (mana, skills, backpacks, currencies...).
public final class ManaSection implements DataSection<ServerPlayer> {
    public String id() { return "mymod:mana"; }
    public Class<ServerPlayer> playerType() { return ServerPlayer.class; }
    public void save(ServerPlayer p, DataNode out) { out.set("value", MyMod.getMana(p)); }
    public void load(ServerPlayer p, DataNode in) { MyMod.setMana(p, in.getDouble("value", 0)); }
    public void clear(ServerPlayer p) { MyMod.setMana(p, 0); }
}
SepareWorldItems.get().sections().register(new ManaSection());

Methods run on the server thread. Each section gets its own node, stored under custom.<id> in the player's record, so ids never clash with built-in keys. Server owners can toggle a section per group with settings.options.saves.<id> in the config.

  • Method Summary

    Modifier and Type
    Method
    Description
    default void
    clear(P player)
    Resets the player's state before the destination data is loaded.
    default boolean
     
    @NotNull String
    id()
     
    void
    load(P player, @NotNull DataNode in)
    Applies saved state.
    @NotNull Class<P>
     
    void
    save(P player, @NotNull DataNode out)
    Writes the player's current state into out (empty node owned by this section).
  • Method Details

    • id

      @NotNull @NotNull String id()
      Returns:
      unique id, namespaced with your plugin/mod id, e.g. "auraskills:mana". Allowed characters: a-z 0-9 _ - :
    • playerType

      @NotNull @NotNull Class<P> playerType()
      Returns:
      the platform player class this section handles; it is ignored on other platforms
    • enabledByDefault

      default boolean enabledByDefault()
      Returns:
      whether the section is saved when the config has no toggle for it
    • save

      void save(@NotNull P player, @NotNull @NotNull DataNode out)
      Writes the player's current state into out (empty node owned by this section).
    • load

      void load(@NotNull P player, @NotNull @NotNull DataNode in)
      Applies saved state. in is empty when the player has no data for this section yet; in that case apply your defaults.
    • clear

      default void clear(@NotNull P player)
      Resets the player's state before the destination data is loaded.