public abstract class PacketAdapter extends java.lang.Object implements PacketListener
Remember to override onPacketReceiving() and onPacketSending(), depending on the ConnectionSide.
Modifier and Type | Class and Description |
---|---|
static class |
PacketAdapter.AdapterParameteters
Represents a builder for passing parameters to the packet adapter constructor.
|
Modifier and Type | Field and Description |
---|---|
protected ConnectionSide |
connectionSide |
protected org.bukkit.plugin.Plugin |
plugin |
protected ListeningWhitelist |
receivingWhitelist |
protected ListeningWhitelist |
sendingWhitelist |
Constructor and Description |
---|
PacketAdapter(PacketAdapter.AdapterParameteters params)
Initialize a packet adapter using a collection of parameters.
|
PacketAdapter(org.bukkit.plugin.Plugin plugin,
ConnectionSide connectionSide,
GamePhase gamePhase,
java.lang.Integer... packets)
Deprecated.
|
PacketAdapter(org.bukkit.plugin.Plugin plugin,
ConnectionSide connectionSide,
GamePhase gamePhase,
java.util.Set<java.lang.Integer> packets)
Deprecated.
|
PacketAdapter(org.bukkit.plugin.Plugin plugin,
ConnectionSide connectionSide,
java.lang.Integer... packets)
Deprecated.
|
PacketAdapter(org.bukkit.plugin.Plugin plugin,
ConnectionSide connectionSide,
ListenerOptions[] options,
java.lang.Integer... packets)
Deprecated.
|
PacketAdapter(org.bukkit.plugin.Plugin plugin,
ConnectionSide connectionSide,
ListenerPriority listenerPriority,
GamePhase gamePhase,
java.lang.Integer... packets)
Deprecated.
|
PacketAdapter(org.bukkit.plugin.Plugin plugin,
ConnectionSide connectionSide,
ListenerPriority listenerPriority,
GamePhase gamePhase,
ListenerOptions[] options,
java.lang.Integer... packets)
Deprecated.
|
PacketAdapter(org.bukkit.plugin.Plugin plugin,
ConnectionSide connectionSide,
ListenerPriority listenerPriority,
GamePhase gamePhase,
java.util.Set<java.lang.Integer> packets)
Deprecated.
|
PacketAdapter(org.bukkit.plugin.Plugin plugin,
ConnectionSide connectionSide,
ListenerPriority listenerPriority,
java.lang.Integer... packets)
Deprecated.
|
PacketAdapter(org.bukkit.plugin.Plugin plugin,
ConnectionSide connectionSide,
ListenerPriority listenerPriority,
java.util.Set<java.lang.Integer> packets)
Deprecated.
|
PacketAdapter(org.bukkit.plugin.Plugin plugin,
java.lang.Iterable<? extends PacketType> types)
Initialize a packet listener with the given parameters.
|
PacketAdapter(org.bukkit.plugin.Plugin plugin,
ListenerPriority listenerPriority,
java.lang.Iterable<? extends PacketType> types)
Initialize a packet listener with the given parameters.
|
PacketAdapter(org.bukkit.plugin.Plugin plugin,
ListenerPriority listenerPriority,
java.lang.Iterable<? extends PacketType> types,
ListenerOptions... options)
Initialize a packet listener with the given 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,
PacketType... types)
Initialize a packet listener with the given parameters.
|
Modifier and Type | Method and Description |
---|---|
org.bukkit.plugin.Plugin |
getPlugin()
Retrieve the plugin that created list packet listener.
|
static java.lang.String |
getPluginName(PacketListener listener)
Retrieves the name of the plugin that has been associated with the listener.
|
static java.lang.String |
getPluginName(org.bukkit.plugin.Plugin plugin)
Retrieves the name of the given plugin.
|
ListeningWhitelist |
getReceivingWhitelist()
Retrieve which packets sent by the client this listener will observe.
|
ListeningWhitelist |
getSendingWhitelist()
Retrieve which packets sent by the server this listener will observe.
|
void |
onPacketReceiving(PacketEvent event)
Invoked right before a received packet from a client is being processed.
|
void |
onPacketSending(PacketEvent event)
Invoked right before a packet is transmitted from the server to the client.
|
static PacketAdapter.AdapterParameteters |
params()
Construct a helper object for passing parameters to the packet adapter.
|
static PacketAdapter.AdapterParameteters |
params(org.bukkit.plugin.Plugin plugin,
java.lang.Integer... packets)
Deprecated.
|
static PacketAdapter.AdapterParameteters |
params(org.bukkit.plugin.Plugin plugin,
PacketType... packets)
Construct a helper object for passing parameters to the packet adapter.
|
java.lang.String |
toString() |
protected org.bukkit.plugin.Plugin plugin
protected ConnectionSide connectionSide
protected ListeningWhitelist receivingWhitelist
protected ListeningWhitelist sendingWhitelist
public PacketAdapter(@Nonnull PacketAdapter.AdapterParameteters params)
params()
to get an instance to this builder.params
- - the parameters.public PacketAdapter(org.bukkit.plugin.Plugin plugin, PacketType... types)
plugin
- - the plugin.listenerPriority
- - the priority.types
- - the packet types.public PacketAdapter(org.bukkit.plugin.Plugin plugin, java.lang.Iterable<? extends PacketType> types)
plugin
- - the plugin.types
- - the packet types.public PacketAdapter(org.bukkit.plugin.Plugin plugin, ListenerPriority listenerPriority, java.lang.Iterable<? extends PacketType> types)
plugin
- - the plugin.listenerPriority
- - the priority.types
- - the packet types.public PacketAdapter(org.bukkit.plugin.Plugin plugin, ListenerPriority listenerPriority, java.lang.Iterable<? extends PacketType> types, ListenerOptions... options)
plugin
- - the plugin.listenerPriority
- - the priority.types
- - the packet types.options
- - the options.public PacketAdapter(org.bukkit.plugin.Plugin plugin, ListenerPriority listenerPriority, PacketType... types)
plugin
- - the plugin.listenerPriority
- - the priority.types
- - the packet types.@Deprecated public PacketAdapter(org.bukkit.plugin.Plugin plugin, ConnectionSide connectionSide, java.lang.Integer... packets)
Deprecated: Use params()
instead.
plugin
- - the plugin that spawned this listener.connectionSide
- - the packet type the listener is looking for.packets
- - the packet IDs the listener is looking for.@Deprecated public PacketAdapter(org.bukkit.plugin.Plugin plugin, ConnectionSide connectionSide, ListenerPriority listenerPriority, java.util.Set<java.lang.Integer> packets)
Deprecated: Use params()
instead.
plugin
- - the plugin that spawned this listener.connectionSide
- - the packet type the listener is looking for.listenerPriority
- - the event priority.packets
- - the packet IDs the listener is looking for.@Deprecated public PacketAdapter(org.bukkit.plugin.Plugin plugin, ConnectionSide connectionSide, GamePhase gamePhase, java.util.Set<java.lang.Integer> packets)
The game phase is used to optimize performance. A listener should only choose BOTH or LOGIN if it's absolutely necessary.
Deprecated: Use params()
instead.
plugin
- - the plugin that spawned this listener.connectionSide
- - the packet type the listener is looking for.gamePhase
- - which game phase this listener is active under.packets
- - the packet IDs the listener is looking for.@Deprecated public PacketAdapter(org.bukkit.plugin.Plugin plugin, ConnectionSide connectionSide, ListenerPriority listenerPriority, GamePhase gamePhase, java.util.Set<java.lang.Integer> packets)
The game phase is used to optimize performance. A listener should only choose BOTH or LOGIN if it's absolutely necessary.
Deprecated: Use params()
instead.
plugin
- - the plugin that spawned this listener.connectionSide
- - the packet type the listener is looking for.listenerPriority
- - the event priority.gamePhase
- - which game phase this listener is active under.packets
- - the packet IDs the listener is looking for.@Deprecated public PacketAdapter(org.bukkit.plugin.Plugin plugin, ConnectionSide connectionSide, ListenerPriority listenerPriority, java.lang.Integer... packets)
Deprecated: Use params()
instead.
plugin
- - the plugin that spawned this listener.connectionSide
- - the packet type the listener is looking for.listenerPriority
- - the event priority.packets
- - the packet IDs the listener is looking for.@Deprecated public PacketAdapter(org.bukkit.plugin.Plugin plugin, ConnectionSide connectionSide, ListenerOptions[] options, java.lang.Integer... packets)
Deprecated: Use params()
instead.
plugin
- - the plugin that spawned this listener.connectionSide
- - the packet type the listener is looking for.options
- - which listener options to use.packets
- - the packet IDs the listener is looking for.@Deprecated public PacketAdapter(org.bukkit.plugin.Plugin plugin, ConnectionSide connectionSide, GamePhase gamePhase, java.lang.Integer... packets)
Deprecated: Use params()
instead.
plugin
- - the plugin that spawned this listener.connectionSide
- - the packet type the listener is looking for.gamePhase
- - which game phase this listener is active under.packets
- - the packet IDs the listener is looking for.@Deprecated public PacketAdapter(org.bukkit.plugin.Plugin plugin, ConnectionSide connectionSide, ListenerPriority listenerPriority, GamePhase gamePhase, java.lang.Integer... packets)
The game phase is used to optimize performance. A listener should only choose BOTH or LOGIN if it's absolutely necessary.
Deprecated: Use params()
instead.
plugin
- - the plugin that spawned this listener.connectionSide
- - the packet type the listener is looking for.listenerPriority
- - the event priority.gamePhase
- - which game phase this listener is active under.packets
- - the packet IDs the listener is looking for.@Deprecated public PacketAdapter(org.bukkit.plugin.Plugin plugin, ConnectionSide connectionSide, ListenerPriority listenerPriority, GamePhase gamePhase, ListenerOptions[] options, java.lang.Integer... packets)
The game phase is used to optimize performance. A listener should only choose BOTH or LOGIN if it's absolutely necessary.
Listener options must be specified in order for NetworkMarker.getInputBuffer()
to function correctly.
Deprecated: Use params()
instead.
plugin
- - the plugin that spawned this listener.connectionSide
- - the packet type the listener is looking for.listenerPriority
- - the event priority.gamePhase
- - which game phase this listener is active under.options
- - which listener options to use.packets
- - the packet IDs the listener is looking for.public void onPacketReceiving(PacketEvent event)
PacketListener
WARNING:
This method will be called asynchronously! You should synchronize with the main
thread using scheduleSyncDelayedTask
if you need to call the Bukkit API.
onPacketReceiving
in interface PacketListener
event
- - the packet that has been received.public void onPacketSending(PacketEvent event)
PacketListener
Note that the packet may be replaced, if needed.
This method is executed on the main thread in 1.6.4 and earlier, and thus the Bukkit API is safe to use.
In Minecraft 1.7.2 and later, this method MAY be executed asynchronously, but only if ListenerOptions.ASYNC
have been specified in the listener. This is off by default.
onPacketSending
in interface PacketListener
event
- - the packet that should be sent.public ListeningWhitelist getReceivingWhitelist()
PacketListener
getReceivingWhitelist
in interface PacketListener
public ListeningWhitelist getSendingWhitelist()
PacketListener
getSendingWhitelist
in interface PacketListener
public org.bukkit.plugin.Plugin getPlugin()
PacketListener
getPlugin
in interface PacketListener
public static java.lang.String getPluginName(PacketListener listener)
listener
- - the listener.public static java.lang.String getPluginName(org.bukkit.plugin.Plugin plugin)
plugin
- - the plugin.public java.lang.String toString()
toString
in class java.lang.Object
public static PacketAdapter.AdapterParameteters params()
This is often simpler and better than passing them directly to each constructor.
@Deprecated public static PacketAdapter.AdapterParameteters params(org.bukkit.plugin.Plugin plugin, java.lang.Integer... packets)
This is often simpler and better than passing them directly to each constructor.
Deprecated: Use params(Plugin, PacketType...)
instead.
plugin
- - the plugin that spawned this listener.packets
- - the packet IDs the listener is looking for.public static PacketAdapter.AdapterParameteters params(org.bukkit.plugin.Plugin plugin, PacketType... packets)
This is often simpler and better than passing them directly to each constructor.
plugin
- - the plugin that spawned this listener.packets
- - the packet types the listener is looking for.