Class PacketSendingEvent

java.lang.Object
org.geysermc.mcprotocollib.network.event.session.PacketSendingEvent
All Implemented Interfaces:
SessionEvent

public class PacketSendingEvent extends Object implements SessionEvent
Called when the session is sending a packet.
  • Constructor Details

    • PacketSendingEvent

      public PacketSendingEvent(Session session, Packet packet)
      Creates a new PacketSendingEvent instance.
      Parameters:
      session - Session sending the packet.
      packet - Packet being sent.
  • Method Details

    • getSession

      public Session getSession()
      Gets the session involved in this event.
      Returns:
      The event's session.
    • getPacket

      public <T extends Packet> T getPacket()
      Gets the packet involved in this event as the required type.
      Type Parameters:
      T - Type of the packet.
      Returns:
      The event's packet as the required type.
      Throws:
      IllegalStateException - If the packet's value isn't of the required type.
    • setPacket

      public void setPacket(Packet packet)
      Sets the packet that should be sent as a result of this event.
      Parameters:
      packet - The packet to send.
    • isCancelled

      public boolean isCancelled()
      Gets whether the event has been cancelled.
      Returns:
      Whether the event has been cancelled.
    • setCancelled

      public void setCancelled(boolean cancelled)
      Sets whether the event should be cancelled.
      Parameters:
      cancelled - Whether the event should be cancelled.
    • call

      public void call(SessionListener listener)
      Description copied from interface: SessionEvent
      Calls the event.
      Specified by:
      call in interface SessionEvent
      Parameters:
      listener - Listener to call the event on.