Package com.comphenix.protocol.events
Interface PacketListener
- All Known Implementing Classes:
MonitorAdapter,PacketAdapter,PacketLogging
public interface PacketListener
Represents a listener that receives notifications when packets are sending or being received.
Use PacketAdapter for a simple wrapper around this interface.
-
Method Summary
Modifier and TypeMethodDescriptionorg.bukkit.plugin.PluginRetrieve the plugin that created list packet listener.Retrieve which packets sent by the client this listener will observe.Retrieve which packets sent by the server this listener will observe.voidonPacketReceiving(PacketEvent event) Invoked right before a received packet from a client is being processed.voidonPacketSending(PacketEvent event) Invoked right before a packet is transmitted from the server to the client.
-
Method Details
-
onPacketSending
Invoked right before a packet is transmitted from the server to the client.Note that the packet may be replaced, if needed.
This method is executed on the main server thread by default. However, some spigot forks (like paper) schedule specific packets off the main thread. If the
ListenerOptions.ASYNCoption is not specified any invocation of this method will be on the main server thread.- Parameters:
event- - the packet that should be sent.
-
onPacketReceiving
Invoked right before a received packet from a client is being processed.This method will be called asynchronously (or on the netty event loop) by default. If the
ListenerOptions.SYNCoption is specified, the invocation of this method will be synced to the main server thread which might cause issues due to delayed packets.- Parameters:
event- - the packet that has been received.
-
getSendingWhitelist
ListeningWhitelist getSendingWhitelist()Retrieve which packets sent by the server this listener will observe.- Returns:
- List of server packets to observe, along with the priority.
-
getReceivingWhitelist
ListeningWhitelist getReceivingWhitelist()Retrieve which packets sent by the client this listener will observe.- Returns:
- List of server packets to observe, along with the priority.
-
getPlugin
org.bukkit.plugin.Plugin getPlugin()Retrieve the plugin that created list packet listener.- Returns:
- The plugin, or NULL if not available.
-