Class PlayerSnapshot

java.lang.Object
com.github.happyuky7.swi.api.data.PlayerSnapshot

public final class PlayerSnapshot extends Object
Saved data of one player in one GroupContext. Immutable: data() returns a copy.

Well-known keys shared by every platform (absent when that section is disabled):

  • gamemode (SURVIVAL, CREATIVE, ADVENTURE, SPECTATOR)
  • allow_flight, flying, fly_speed
  • exp (progress 0..1), exp-level
  • hunger, health, max-health
  • inventory.<slot>, armor_contents.<helmet|chestplate|leggings|boots>, off_hand_item, ender-chest.<slot> (item format depends on format())
  • potion_effect.<n>.type|duration|amplifier
  • custom.<sectionId>... for sections registered through the API
  • Field Details

    • FORMAT_BUKKIT

      public static final String FORMAT_BUKKIT
      Items serialized by Bukkit's ConfigurationSerializable (plugin, historical format).
      See Also:
    • FORMAT_SNBT

      public static final String FORMAT_SNBT
      Items serialized as SNBT strings by the Fabric mod.
      See Also:
  • Constructor Details

    • PlayerSnapshot

      public PlayerSnapshot(@NotNull @NotNull UUID uuid, @Nullable @Nullable String playerName, @NotNull @NotNull GroupContext context, @NotNull @NotNull DataNode data)
  • Method Details

    • uuid

      @NotNull public @NotNull UUID uuid()
    • playerName

      @Nullable public @Nullable String playerName()
    • context

      @NotNull public @NotNull GroupContext context()
    • data

      @NotNull public @NotNull DataNode data()
      Returns:
      a mutable copy of all saved values
    • format

      @NotNull public @NotNull String format()
      Returns:
      FORMAT_BUKKIT or FORMAT_SNBT
    • dataVersion

      public int dataVersion()
      Returns:
      Minecraft data version the items were saved with, or -1 when unknown
    • gamemode

      @Nullable public @Nullable String gamemode()
    • expLevel

      @Nullable public @Nullable Integer expLevel()
    • exp

      @Nullable public @Nullable Float exp()
    • health

      @Nullable public @Nullable Double health()
    • hunger

      @Nullable public @Nullable Integer hunger()
    • customSection

      @Nullable public @Nullable DataNode customSection(@NotNull @NotNull String sectionId)
      Returns:
      the data a custom DataSection stored, or null