Klasse PlayerStash

java.lang.Object
de.delinkedde.mobarenareborn.player.PlayerStash

public final class PlayerStash extends Object
A snapshot of a player's state taken when they join an arena, used to restore them on leave.

The snapshot captures the inventory (including armor and off-hand), game mode, experience, hunger, the maximum-health attribute and active potion effects, plus the location to return to. Restoring resets the max-health attribute (undoing a class's base-health and health-boost changes) and heals the player to full, so hearts return to normal after a round. The originating player is never referenced after capture, so the snapshot is safe to hold across sessions.

  • Methodendetails

    • capture

      @NotNull public static @NotNull PlayerStash capture(@NotNull @NotNull Player player)
      Captures the current state of the given player.
      Parameter:
      player - the player to snapshot
      Gibt zurück:
      an immutable snapshot
    • restore

      public void restore(@NotNull @NotNull Player player)
      Restores this snapshot onto the given player and teleports them back to the captured location.
      Parameter:
      player - the player to restore
    • contentsCopy

      @NotNull public @NotNull ItemStack[] contentsCopy()
      Gibt zurück:
      a deep copy of the captured inventory contents (for the my-items class)
    • clear

      public static void clear(@NotNull @NotNull Player player)
      Clears a player's inventory, effects and transient combat state in preparation for entering an arena. Does not capture anything; pair with capture(Player).
      Parameter:
      player - the player to clear
    • writeTo

      public void writeTo(@NotNull @NotNull ConfigurationSection section)
      Writes this snapshot into a configuration section so it survives a server crash.
      Parameter:
      section - the section to write into
    • readFrom

      @Nullable public static @Nullable PlayerStash readFrom(@NotNull @NotNull ConfigurationSection section)
      Reads a snapshot back from a configuration section.
      Parameter:
      section - the section to read from
      Gibt zurück:
      the snapshot, or null if the section is incomplete