Class AgentEventEncoders
player.command,
player.join/player.leave and error.report.
Each method returns a payload JsonObject that the connection wraps in an envelope, or
null when the input cannot satisfy the contract. A null means "do not send":
the gateway answers a non-conforming frame with invalid_message and closes, so dropping
an unencodable event locally is the only safe answer. No method throws.
Redaction. Text handed to these encoders is already redacted by the phase's builders
(D-20): an error report's message, trigger detail and stack trace come from the collector's
serialisation path, which replaces a sensitive command's arguments with ***. A
player.command payload carries the command name only because the schema has no field for
an argument (D-20).
Package-private: wired by the session plan (22-22), not part of the public API.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescription(package private) static interfaceThe values anerror.reportpayload is built from, as the session plan maps them out of the error-report collector's report. -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final Patternpackages/contracts: player.command payload name.private static final intprivate static final intprivate static final Patternpackages/contracts: error.report fingerprint, at least eight lower-case hex digits.private static final intThe fingerprint width the collector'sInteger.toHexStringoutput is padded to.private static final intprivate static final longprivate static final intprivate static final intprivate static final intprivate static final longprivate static final longprivate static final intprivate static final double -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate static voidaddNullableText(com.google.gson.JsonObject payload, String key, String value) private static StringCuts a string to a number of code points, so a supplementary character is never split into an unpaired surrogate.(package private) static com.google.gson.JsonObjectEncodes anerror.reportpayload.private static Stringfingerprint(String raw) Left-pads the collector's fingerprint with zeros to the contract's minimum width without changing it otherwise, so a panel error group keeps the same id across restarts and versions.private static com.google.gson.JsonElementprivate static com.google.gson.JsonElementprivate static com.google.gson.JsonElementonlinePlayers(Long value) private static StringoptionalText(String value) Trims a short field and turns a blank one into null, which the contract allows where an empty string would fail itsminLength.(package private) static com.google.gson.JsonObjectplayerCommand(String normalisedName) Encodes aplayer.commandpayload.private static StringplayerName(String raw) Keeps a player name only when the contract's name pattern accepts it.(package private) static com.google.gson.JsonObjectEncodes the payload shared byplayer.joinandplayer.leave.private static longseenAt(long value) private static com.google.gson.JsonObjectClamps a snapshot to the contract's shape: four keys, each a number or JSON null.private static com.google.gson.JsonElementprivate static StringtriggerKind(String raw) Maps a trigger type onto the contract's enumeration.
-
Field Details
-
COMMAND_NAME
packages/contracts: player.command payload name. -
FINGERPRINT
packages/contracts: error.report fingerprint, at least eight lower-case hex digits. -
EXCEPTION_TYPE_MAX
private static final int EXCEPTION_TYPE_MAX- See Also:
-
MESSAGE_MAX
private static final int MESSAGE_MAX- See Also:
-
STACK_TRACE_MAX
private static final int STACK_TRACE_MAX- See Also:
-
MODULE_NAME_MAX
private static final int MODULE_NAME_MAX- See Also:
-
DETAIL_MAX
private static final int DETAIL_MAX- See Also:
-
LOCATION_MAX
private static final int LOCATION_MAX- See Also:
-
OCCURRENCES_MAX
private static final int OCCURRENCES_MAX- See Also:
-
TPS_MAX
private static final double TPS_MAX- See Also:
-
MEMORY_MB_MAX
private static final long MEMORY_MB_MAX- See Also:
-
ONLINE_PLAYERS_MAX
private static final long ONLINE_PLAYERS_MAX- See Also:
-
SEEN_AT_MAX
private static final long SEEN_AT_MAX- See Also:
-
FINGERPRINT_WIDTH
private static final int FINGERPRINT_WIDTHThe fingerprint width the collector'sInteger.toHexStringoutput is padded to.- See Also:
-
-
Constructor Details
-
AgentEventEncoders
private AgentEventEncoders()
-
-
Method Details
-
playerCommand
Encodes aplayer.commandpayload.- Parameters:
normalisedName- the command name after the framework's normalisation (leading slash and namespace removed, lower-cased), or null- Returns:
{ name }when the name satisfies the schema, otherwise null
-
playerRef
Encodes the payload shared byplayer.joinandplayer.leave.- Parameters:
uuid- the player's UUID in canonical lower-case hyphenated form, or nullname- the player's name, including a Floodgate prefix, or null- Returns:
{ playerUuid, playerName }when both satisfy the contract, otherwise null
-
errorReport
Encodes anerror.reportpayload.Bounds are applied, not rejected: text is cut to its contract length, occurrence counts below one become one, and a player name that cannot satisfy the schema becomes JSON null, because losing one optional field is better than losing the report. Only a payload that could never be valid — a fingerprint that is not hexadecimal, an empty exception type — returns null.
- Parameters:
view- the report's values, or null- Returns:
- the payload, or null when it cannot be made valid
-
fingerprint
Left-pads the collector's fingerprint with zeros to the contract's minimum width without changing it otherwise, so a panel error group keeps the same id across restarts and versions.- Parameters:
raw- the collector's fingerprint, or null- Returns:
- a lower-case hexadecimal fingerprint of at least eight digits, or null
-
snapshot
Clamps a snapshot to the contract's shape: four keys, each a number or JSON null.- Parameters:
view- the report's values- Returns:
- the snapshot object
-
tps
-
megabytes
-
onlinePlayers
-
triggerKind
Maps a trigger type onto the contract's enumeration.The collector stores
TriggerContext.TriggerType#name():COMMAND,EVENT,SCHEDULED,AOPandUNCAUGHT. The contract knows onlyevent,command,schedulerandother, so an AOP interception and an uncaught exception report asother, and so does anything else unknown. Matching ignores case, so the contract's own names pass through as they are.- Parameters:
raw- the collector's trigger type, or null- Returns:
- one of
event,command,scheduler,other
-
playerName
Keeps a player name only when the contract's name pattern accepts it.- Parameters:
raw- the player's name, or null- Returns:
- the name, or null when it cannot be sent
-
cut
Cuts a string to a number of code points, so a supplementary character is never split into an unpaired surrogate.- Parameters:
value- the text, possibly nullmaxCodePoints- the largest allowed length in code points- Returns:
- the text, cut when longer; an empty string for null
-
optionalText
Trims a short field and turns a blank one into null, which the contract allows where an empty string would fail itsminLength.- Parameters:
value- the already cut text, possibly null- Returns:
- the trimmed text, or null when blank
-
addNullableText
-
jsonOf
-
seenAt
private static long seenAt(long value)
-