public class PacketEvent
extends java.util.EventObject
implements org.bukkit.event.Cancellable
Constructor and Description |
---|
PacketEvent(java.lang.Object source)
Use the static constructors to create instances of this event.
|
Modifier and Type | Method and Description |
---|---|
static PacketEvent |
fromClient(java.lang.Object source,
PacketContainer packet,
org.bukkit.entity.Player client)
Creates an event representing a client packet transmission.
|
static PacketEvent |
fromServer(java.lang.Object source,
PacketContainer packet,
org.bukkit.entity.Player recipient)
Creates an event representing a server packet transmission.
|
static PacketEvent |
fromSynchronous(PacketEvent event,
AsyncMarker marker)
Create an asynchronous packet event from a synchronous event and a async marker.
|
AsyncMarker |
getAsyncMarker()
Retrieve the asynchronous marker.
|
PacketContainer |
getPacket()
Retrieves the packet that will be sent to the player.
|
int |
getPacketID()
Retrieves the packet ID.
|
org.bukkit.entity.Player |
getPlayer()
Retrieves the player that has sent the packet or is recieving it.
|
boolean |
isAsynchronous()
Determine if the packet event has been executed asynchronously or not.
|
boolean |
isCancelled()
Retrieves whether or not the packet should be cancelled.
|
boolean |
isServerPacket()
Whether or not this packet was created by the server.
|
void |
setAsyncMarker(AsyncMarker asyncMarker)
Set the asynchronous marker.
|
void |
setCancelled(boolean cancel)
Sets whether or not the packet should be cancelled.
|
void |
setPacket(PacketContainer packet)
Replace the packet that will be sent to the player.
|
public PacketEvent(java.lang.Object source)
source
- - the event source.public static PacketEvent fromClient(java.lang.Object source, PacketContainer packet, org.bukkit.entity.Player client)
source
- - the event source.packet
- - the packet.client
- - the client that sent the packet.public static PacketEvent fromServer(java.lang.Object source, PacketContainer packet, org.bukkit.entity.Player recipient)
source
- - the event source.packet
- - the packet.recipient
- - the client that will receieve the packet.public static PacketEvent fromSynchronous(PacketEvent event, AsyncMarker marker)
event
- - the original synchronous event.marker
- - the asynchronous marker.public PacketContainer getPacket()
public void setPacket(PacketContainer packet)
packet
- - the packet that will be sent instead.public int getPacketID()
public boolean isCancelled()
isCancelled
in interface org.bukkit.event.Cancellable
public void setCancelled(boolean cancel)
setCancelled
in interface org.bukkit.event.Cancellable
cancel
- - TRUE if it should be cancelled, FALSE otherwise.public org.bukkit.entity.Player getPlayer()
public boolean isServerPacket()
Most listeners can deduce this by noting which listener method was invoked.
public AsyncMarker getAsyncMarker()
If the packet is synchronous, this marker will be used to schedule an asynchronous event. In the following asynchronous event, the marker is used to correctly pass the packet around to the different threads.
Note that if there are no asynchronous events that can receive this packet, the marker is NULL.
public void setAsyncMarker(AsyncMarker asyncMarker)
If the marker is non-null at the end of an synchronous event processing, the packet will be scheduled to be processed asynchronously with the given settings.
Note that if there are no asynchronous events that can receive this packet, the marker should be NULL.
asyncMarker
- - the new asynchronous marker, or NULL.java.lang.IllegalStateException
- If the current event is asynchronous.public boolean isAsynchronous()