Class PlayerSnapshots

java.lang.Object
eu.mrapik.minecraftservermcp.builtin.player.PlayerSnapshots

public final class PlayerSnapshots extends Object
Serializes live Player data into ordered maps and JSON strings for the players_list and player_get MCP resources.

Field names and types are stable enough for MCP clients to parse; they mirror common server state (position, health, game mode) and intentionally avoid NBT or deep inventory data.

  • Method Details

    • map

      public static Map<String,Object> map(Player p)
      Flat map suitable for Jackson; keys use camelCase consistent with JSON conventions.
      Parameters:
      p - online player
      Returns:
      ordered map of snapshot fields
    • toJson

      public static String toJson(Object value) throws IOException
      Serializes snapshot data to a JSON string using the shared JSON mapper.
      Parameters:
      value - map from map(Player) or a list of such maps
      Returns:
      JSON string
      Throws:
      IOException - if serialization fails