Klasse PlayerStash
java.lang.Object
de.delinkedde.mobarenareborn.player.PlayerStash
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.
-
Methodenübersicht
Modifizierer und TypMethodeBeschreibungstatic @NotNull PlayerStashCaptures the current state of the given player.static voidClears a player's inventory, effects and transient combat state in preparation for entering an arena.@NotNull ItemStack[]static @Nullable PlayerStashreadFrom(@NotNull ConfigurationSection section) Reads a snapshot back from a configuration section.voidRestores this snapshot onto the given player and teleports them back to the captured location.voidwriteTo(@NotNull ConfigurationSection section) Writes this snapshot into a configuration section so it survives a server crash.
-
Methodendetails
-
capture
Captures the current state of the given player.- Parameter:
player- the player to snapshot- Gibt zurück:
- an immutable snapshot
-
restore
Restores this snapshot onto the given player and teleports them back to the captured location.- Parameter:
player- the player to restore
-
contentsCopy
- Gibt zurück:
- a deep copy of the captured inventory contents (for the my-items class)
-
clear
Clears a player's inventory, effects and transient combat state in preparation for entering an arena. Does not capture anything; pair withcapture(Player).- Parameter:
player- the player to clear
-
writeTo
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
nullif the section is incomplete
-