Class NetworkMarker

java.lang.Object
com.comphenix.protocol.events.NetworkMarker

public class NetworkMarker extends Object
Marker containing the serialized packet data seen from the network, or output handlers that will serialize the current packet.
  • Constructor Details

    • NetworkMarker

      public NetworkMarker(@Nonnull ConnectionSide side, PacketType type)
      Construct a new network marker.

      The input buffer is only non-null for client-side packets.

      Parameters:
      side - - which side this marker belongs to.
      type - - packet type
  • Method Details

    • hasPostListeners

      public static boolean hasPostListeners(NetworkMarker marker)
      Determine if the given marker has any post listeners.
      Parameters:
      marker - - the marker to check.
      Returns:
      TRUE if it does, FALSE otherwise.
    • getNetworkMarker

      public static NetworkMarker getNetworkMarker(PacketEvent event)
      Retrieve the network marker of a particular event without creating it.

      This is an internal method that should not be used by API users.

      Parameters:
      event - - the event.
      Returns:
      The network marker.
    • readScheduledPackets

      public static Deque<ScheduledPacket> readScheduledPackets(NetworkMarker marker)
      Retrieve the scheduled packets of a particular network marker without constructing the list.

      This is an internal method that should not be used by API users.

      Parameters:
      marker - - the marker.
      Returns:
      The list, or NULL if not found or initialized.
    • getSide

      public ConnectionSide getSide()
      Retrieve whether or not this marker belongs to a client or a server side packet.
      Returns:
      The side the parent packet belongs to.
    • getType

      public PacketType getType()
    • addPostListener

      public boolean addPostListener(PacketPostListener listener)
      Add a listener that is invoked after a packet has been successfully sent to the client, or received by the server.

      Received packets are not guarenteed to have been fully processed, but packets passed to PacketStream.receiveClientPacket(Player, PacketContainer) will be processed after the current packet event.

      Note that post listeners will be executed asynchronously off the main thread. They are not executed in any defined order.

      Parameters:
      listener - - the listener that will be invoked.
      Returns:
      TRUE if it was added.
    • removePostListener

      public boolean removePostListener(PacketPostListener listener)
      Remove the first instance of the given listener.
      Parameters:
      listener - - listener to remove.
      Returns:
      TRUE if it was removed, FALSE otherwise.
    • getPostListeners

      public Set<PacketPostListener> getPostListeners()
      Retrieve an immutable view of all the listeners that will be invoked once the packet has been sent or received.
      Returns:
      Every post packet listener. Never NULL.
    • getScheduledPackets

      public Deque<ScheduledPacket> getScheduledPackets()
      Retrieve a modifiable queue of packets that will be schedule (in-order) when the current packet has been successfully transmitted.
      Returns:
      the queue of packets to schedule after this packet, in order.