public abstract class PacketAdapter extends java.lang.Object implements PacketListener
Remember to override onPacketReceiving() and onPacketSending(), depending on the ConnectionSide.
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(org.bukkit.plugin.Plugin plugin,
ConnectionSide connectionSide,
GamePhase gamePhase,
java.lang.Integer... packets)
Initialize a packet listener for a single connection side.
|
PacketAdapter(org.bukkit.plugin.Plugin plugin,
ConnectionSide connectionSide,
GamePhase gamePhase,
java.util.Set<java.lang.Integer> packets)
Initialize a packet listener for a single connection side.
|
PacketAdapter(org.bukkit.plugin.Plugin plugin,
ConnectionSide connectionSide,
java.lang.Integer... packets)
Initialize a packet listener with default priority.
|
PacketAdapter(org.bukkit.plugin.Plugin plugin,
ConnectionSide connectionSide,
ListenerPriority listenerPriority,
GamePhase gamePhase,
java.lang.Integer... packets)
Initialize a packet listener for a single connection side.
|
PacketAdapter(org.bukkit.plugin.Plugin plugin,
ConnectionSide connectionSide,
ListenerPriority listenerPriority,
GamePhase gamePhase,
java.util.Set<java.lang.Integer> packets)
Initialize a packet listener for a single connection side.
|
PacketAdapter(org.bukkit.plugin.Plugin plugin,
ConnectionSide connectionSide,
ListenerPriority listenerPriority,
java.lang.Integer... packets)
Initialize a packet listener for a single connection side.
|
PacketAdapter(org.bukkit.plugin.Plugin plugin,
ConnectionSide connectionSide,
ListenerPriority listenerPriority,
java.util.Set<java.lang.Integer> packets)
Initialize a packet listener for a single connection side.
|
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 recieved packet from a client is being processed.
|
void |
onPacketSending(PacketEvent event)
Invoked right before a packet is transmitted from the server to the client.
|
java.lang.String |
toString() |
protected org.bukkit.plugin.Plugin plugin
protected ConnectionSide connectionSide
protected ListeningWhitelist receivingWhitelist
protected ListeningWhitelist sendingWhitelist
public PacketAdapter(org.bukkit.plugin.Plugin plugin, ConnectionSide connectionSide, java.lang.Integer... packets)
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.public PacketAdapter(org.bukkit.plugin.Plugin plugin, ConnectionSide connectionSide, ListenerPriority listenerPriority, java.util.Set<java.lang.Integer> packets)
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.public PacketAdapter(org.bukkit.plugin.Plugin plugin, ConnectionSide connectionSide, GamePhase gamePhase, java.util.Set<java.lang.Integer> packets)
The game phase is used to optmize performance. A listener should only choose BOTH or LOGIN if it's absolutely necessary.
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.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 optmize performance. A listener should only choose BOTH or LOGIN if it's absolutely necessary.
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.public PacketAdapter(org.bukkit.plugin.Plugin plugin, ConnectionSide connectionSide, ListenerPriority listenerPriority, java.lang.Integer... packets)
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.public PacketAdapter(org.bukkit.plugin.Plugin plugin, ConnectionSide connectionSide, GamePhase gamePhase, java.lang.Integer... packets)
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.public PacketAdapter(org.bukkit.plugin.Plugin plugin, ConnectionSide connectionSide, ListenerPriority listenerPriority, GamePhase gamePhase, java.lang.Integer... packets)
The game phase is used to optmize performance. A listener should only choose BOTH or LOGIN if it's absolutely necessary.
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.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 recieved.public void onPacketSending(PacketEvent event)
PacketListener
Note that the packet may be replaced, if needed.
This method is executed on the main thread, and thus the Bukkit API is safe to use.
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