Class PacketSendingEvent
java.lang.Object
org.geysermc.mcprotocollib.network.event.session.PacketSendingEvent
- All Implemented Interfaces:
SessionEvent
Called when the session is sending a packet.
-
Constructor Summary
ConstructorsConstructorDescriptionPacketSendingEvent(Session session, Packet packet) Creates a new PacketSendingEvent instance. -
Method Summary
Modifier and TypeMethodDescriptionvoidcall(SessionListener listener) Calls the event.Gets the packet involved in this event as the required type.Gets the session involved in this event.booleanGets whether the event has been cancelled.voidsetCancelled(boolean cancelled) Sets whether the event should be cancelled.voidSets the packet that should be sent as a result of this event.
-
Constructor Details
-
PacketSendingEvent
Creates a new PacketSendingEvent instance.- Parameters:
session- Session sending the packet.packet- Packet being sent.
-
-
Method Details
-
getSession
Gets the session involved in this event.- Returns:
- The event's session.
-
getPacket
Gets the packet involved in this event as the required type.- Returns:
- The event's packet as the required type.
- Throws:
IllegalStateException- If the packet's value isn't of the required type.
-
setPacket
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
Description copied from interface:SessionEventCalls the event.- Specified by:
callin interfaceSessionEvent- Parameters:
listener- Listener to call the event on.
-