Class CloudOutboxListener

java.lang.Object
com.ultikits.ultitools.utils.CloudOutboxListener
All Implemented Interfaces:
org.bukkit.event.Listener

@Internal public final class CloudOutboxListener extends Object implements org.bukkit.event.Listener
Captures player joins and leaves into the current UltiCloud session's reliable-delivery outbox (D-14, D-17, S-16), whether or not the connection is open: the outbox exists precisely to carry an event across a disconnect (contract answer 15).

Public because UltiTools constructs it from another package. The registration in UltiTools#onEnable() lives in com.ultikits.ultitools, so the class and its no-argument constructor have to be visible there; made package-private, it could not be instantiated from that package at all (S-03). Bukkit is not the reason: Paper registers listener classes through its method-handle fallback and does not require them to be public. Nothing else here is public surface: the handler bodies and the payload builder are implementation details, and the class is marked ApiStatus.Internal so no module treats it as API.

Registered once, decided per event. UltiTools#onEnable() registers this listener a single time, beside PlayerJoinListener, and never unregisters it while the plugin is enabled. Whether an event is captured is decided at event time by CloudSession.offerReliableEvent(String, JsonObject), which returns silently when the server holds no credential or ultipanel.capabilities.player-events is off (S-16). The listener is therefore never registered or unregistered from an asynchronous thread, and an unlinked server writes no state file at all.

Payload. payloadFor(Player) is the single builder of a player.join / player.leave payload; it delegates to the contract encoder (plan 22-13 through AgentOutboundFeeds.playerRefPayload(java.lang.String, java.lang.String), plan 22-22), which emits exactly two keys: playerUuid (the UUID string) and playerName (the name the server reports, a Floodgate prefix such as .Steve included). A player the contract cannot carry is skipped with one FINE line. No IP address, display name, location or online-mode flag ever reaches the outbox (T-22-29, contract answer 15).

Commands (plan 22-22). A player's command is reported live, never buffered (D-14), as player.command carrying only the normalised command name (D-20): the arguments of any command, registered as sensitive or not, never leave the server.

Known limitation. A quit fired after the plugin has already been disabled during a server stop is not captured: Bukkit stops dispatching to a disabled plugin's listeners. The plugin's own shutdown flush still persists everything captured before that point. Whether the CraftBukkit stop sequence disables plugins before it removes players is not verified here: the UAT row ultitools.cloud.outbox.persist-restart (plan 22-28) observes it on a real server, and the limitation itself belongs on the COMPATIBILITY.md known-limitations list (plan 22-27).

Since:
6.3.1
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    private static void
    offer(String type, org.bukkit.entity.Player player)
    Hands one event to the session that is current now, not the one captured at registration time: a login replaces the session, and the replacement owns the outbox the event belongs in.
    void
    onCommand(org.bukkit.event.player.PlayerCommandPreprocessEvent event)
    Reports one player command to the live connection by its name only (D-20).
    void
    onJoin(org.bukkit.event.player.PlayerJoinEvent event)
    Adds one player.join entry to the current session's outbox.
    void
    onQuit(org.bukkit.event.player.PlayerQuitEvent event)
    Adds one player.leave entry to the current session's outbox.
    (package private) static com.google.gson.JsonObject
    payloadFor(org.bukkit.entity.Player player)
    The one builder of a join/leave payload (T-22-29).

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • CloudOutboxListener

      public CloudOutboxListener()
  • Method Details

    • onJoin

      public void onJoin(org.bukkit.event.player.PlayerJoinEvent event)
      Adds one player.join entry to the current session's outbox.
      Parameters:
      event - the join event, on the main thread
    • onQuit

      public void onQuit(org.bukkit.event.player.PlayerQuitEvent event)
      Adds one player.leave entry to the current session's outbox. A kick ends in a quit, so a kicked player produces exactly this one entry.
      Parameters:
      event - the quit event, on the main thread
    • onCommand

      public void onCommand(org.bukkit.event.player.PlayerCommandPreprocessEvent event)
      Reports one player command to the live connection by its name only (D-20). Nothing is sent while no connection is established or ultipanel.capabilities.player-events is off. A command another plugin cancelled (a login plugin before the player logged in, a permission plugin) was not run, so it is not reported (22-22 fix).
      Parameters:
      event - the command event, on the main thread
    • offer

      private static void offer(String type, org.bukkit.entity.Player player)
      Hands one event to the session that is current now, not the one captured at registration time: a login replaces the session, and the replacement owns the outbox the event belongs in.
      Parameters:
      type - the envelope type
      player - the player the event is about
    • payloadFor

      static com.google.gson.JsonObject payloadFor(org.bukkit.entity.Player player)
      The one builder of a join/leave payload (T-22-29). Kept package-private so a test can assert the exact key set without a live server.
      Parameters:
      player - the player the event is about
      Returns:
      a fresh payload object the outbox copies, or null when the contract cannot carry this player