Class PacketAdapter
- All Implemented Interfaces:
PacketListener
Remember to override onPacketReceiving() and onPacketSending(), depending on the ConnectionSide.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classRepresents a builder for passing parameters to the packet adapter constructor. -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected ConnectionSideprotected org.bukkit.plugin.Pluginprotected ListeningWhitelistprotected ListeningWhitelist -
Constructor Summary
ConstructorsConstructorDescriptionInitialize a packet adapter using a collection of parameters.PacketAdapter(org.bukkit.plugin.Plugin plugin, ListenerPriority listenerPriority, PacketType... types) Initialize a packet listener with the given parameters.PacketAdapter(org.bukkit.plugin.Plugin plugin, ListenerPriority listenerPriority, Iterable<? extends PacketType> types) Initialize a packet listener with the given parameters.PacketAdapter(org.bukkit.plugin.Plugin plugin, ListenerPriority listenerPriority, Iterable<? extends PacketType> types, ListenerOptions... options) Initialize a packet listener with the given parameters.PacketAdapter(org.bukkit.plugin.Plugin plugin, PacketType... types) Initialize a packet listener with the given parameters.PacketAdapter(org.bukkit.plugin.Plugin plugin, Iterable<? extends PacketType> types) Initialize a packet listener with the given parameters. -
Method Summary
Modifier and TypeMethodDescriptionorg.bukkit.plugin.PluginRetrieve the plugin that created list packet listener.static StringgetPluginName(PacketListener listener) Retrieves the name of the plugin that has been associated with the listener.static StringgetPluginName(org.bukkit.plugin.Plugin plugin) Retrieves the name of the given plugin.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.params()Construct a helper object for passing parameters to the packet adapter.params(org.bukkit.plugin.Plugin plugin, PacketType... packets) Construct a helper object for passing parameters to the packet adapter.toString()
-
Field Details
-
plugin
protected org.bukkit.plugin.Plugin plugin -
connectionSide
-
receivingWhitelist
-
sendingWhitelist
-
-
Constructor Details
-
PacketAdapter
Initialize a packet adapter using a collection of parameters. Useparams()to get an instance to this builder.- Parameters:
params- - the parameters.
-
PacketAdapter
Initialize a packet listener with the given parameters.- Parameters:
plugin- - the plugin.types- - the packet types.
-
PacketAdapter
Initialize a packet listener with the given parameters.- Parameters:
plugin- - the plugin.types- - the packet types.
-
PacketAdapter
public PacketAdapter(org.bukkit.plugin.Plugin plugin, ListenerPriority listenerPriority, Iterable<? extends PacketType> types) Initialize a packet listener with the given parameters.- Parameters:
plugin- - the plugin.listenerPriority- - the priority.types- - the packet types.
-
PacketAdapter
public PacketAdapter(org.bukkit.plugin.Plugin plugin, ListenerPriority listenerPriority, Iterable<? extends PacketType> types, ListenerOptions... options) Initialize a packet listener with the given parameters.- Parameters:
plugin- - the plugin.listenerPriority- - the priority.types- - the packet types.options- - the options.
-
PacketAdapter
public PacketAdapter(org.bukkit.plugin.Plugin plugin, ListenerPriority listenerPriority, PacketType... types) Initialize a packet listener with the given parameters.- Parameters:
plugin- - the plugin.listenerPriority- - the priority.types- - the packet types.
-
-
Method Details
-
getPluginName
Retrieves the name of the plugin that has been associated with the listener.- Parameters:
listener- - the listener.- Returns:
- Name of the associated plugin.
-
getPluginName
Retrieves the name of the given plugin.- Parameters:
plugin- - the plugin.- Returns:
- Name of the given plugin.
-
params
Construct a helper object for passing parameters to the packet adapter.This is often simpler and better than passing them directly to each constructor.
- Returns:
- Helper object.
-
params
public static PacketAdapter.AdapterParameteters params(org.bukkit.plugin.Plugin plugin, PacketType... packets) Construct a helper object for passing parameters to the packet adapter.This is often simpler and better than passing them directly to each constructor.
- Parameters:
plugin- - the plugin that spawned this listener.packets- - the packet types the listener is looking for.- Returns:
- Helper object.
-
onPacketReceiving
Description copied from interface:PacketListenerInvoked 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.- Specified by:
onPacketReceivingin interfacePacketListener- Parameters:
event- - the packet that has been received.
-
onPacketSending
Description copied from interface:PacketListenerInvoked 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.- Specified by:
onPacketSendingin interfacePacketListener- Parameters:
event- - the packet that should be sent.
-
getReceivingWhitelist
Description copied from interface:PacketListenerRetrieve which packets sent by the client this listener will observe.- Specified by:
getReceivingWhitelistin interfacePacketListener- Returns:
- List of server packets to observe, along with the priority.
-
getSendingWhitelist
Description copied from interface:PacketListenerRetrieve which packets sent by the server this listener will observe.- Specified by:
getSendingWhitelistin interfacePacketListener- Returns:
- List of server packets to observe, along with the priority.
-
getPlugin
public org.bukkit.plugin.Plugin getPlugin()Description copied from interface:PacketListenerRetrieve the plugin that created list packet listener.- Specified by:
getPluginin interfacePacketListener- Returns:
- The plugin, or NULL if not available.
-
toString
-