public interface ProtocolManager extends PacketStream
Modifier and Type | Method and Description |
---|---|
void |
addPacketListener(PacketListener listener)
Adds a packet listener.
|
void |
broadcastServerPacket(PacketContainer packet)
Broadcast a given packet to every connected player on the server.
|
void |
broadcastServerPacket(PacketContainer packet,
org.bukkit.entity.Entity entity,
boolean includeTracker)
Broadcast a packet to every player that is receiving information about a given entity.
|
void |
broadcastServerPacket(PacketContainer packet,
org.bukkit.Location origin,
int maxObserverDistance)
Broadcast a packet to every player within the given maximum observer distance.
|
PacketContainer |
createPacket(int id)
Deprecated.
|
PacketContainer |
createPacket(int id,
boolean forceDefaults)
Deprecated.
|
PacketContainer |
createPacket(PacketType type)
Constructs a new encapsulated Minecraft packet with the given ID.
|
PacketContainer |
createPacket(PacketType type,
boolean forceDefaults)
Constructs a new encapsulated Minecraft packet with the given ID.
|
PacketConstructor |
createPacketConstructor(int id,
java.lang.Object... arguments)
Deprecated.
|
PacketConstructor |
createPacketConstructor(PacketType type,
java.lang.Object... arguments)
Construct a packet using the special builtin Minecraft constructors.
|
AsynchronousManager |
getAsynchronousManager()
Retrieve the current asynchronous packet manager.
|
org.bukkit.entity.Entity |
getEntityFromID(org.bukkit.World container,
int id)
Retrieve the associated entity.
|
java.util.List<org.bukkit.entity.Player> |
getEntityTrackers(org.bukkit.entity.Entity entity)
Retrieve every client that is receiving information about a given entity.
|
MinecraftVersion |
getMinecraftVersion()
Retrieve the current Minecraft version.
|
com.google.common.collect.ImmutableSet<PacketListener> |
getPacketListeners()
Retrieves a list of every registered packet listener.
|
java.util.Set<java.lang.Integer> |
getReceivingFilters()
Deprecated.
|
java.util.Set<PacketType> |
getReceivingFilterTypes()
Retrieves a immutable set containing the type of the received client packets that will be observed by listeners.
|
java.util.Set<java.lang.Integer> |
getSendingFilters()
Deprecated.
|
java.util.Set<PacketType> |
getSendingFilterTypes()
Retrieves a immutable set containing the type of the sent server packets that will be observed by listeners.
|
boolean |
isClosed()
Determines whether or not this protocol manager has been disabled.
|
void |
recieveClientPacket(org.bukkit.entity.Player sender,
PacketContainer packet,
boolean filters)
Simulate receiving a certain packet from a given player.
|
void |
removePacketListener(PacketListener listener)
Removes a given packet listener.
|
void |
removePacketListeners(org.bukkit.plugin.Plugin plugin)
Removes every listener associated with the given plugin.
|
void |
sendServerPacket(org.bukkit.entity.Player receiver,
PacketContainer packet,
boolean filters)
Send a packet to the given player.
|
void |
updateEntity(org.bukkit.entity.Entity entity,
java.util.List<org.bukkit.entity.Player> observers)
Completely resend an entity to a list of clients.
|
recieveClientPacket, recieveClientPacket, sendServerPacket, sendServerPacket
void sendServerPacket(org.bukkit.entity.Player receiver, PacketContainer packet, boolean filters) throws java.lang.reflect.InvocationTargetException
Re-sending a previously cancelled packet is discouraged. Use AsyncMarker.incrementProcessingDelay()
to delay a packet until a certain condition has been met.
sendServerPacket
in interface PacketStream
receiver
- - the receiver.packet
- - packet to send.filters
- - whether or not to invoke any packet filters below ListenerPriority.MONITOR
.java.lang.reflect.InvocationTargetException
- - if an error occurred when sending the packet.void recieveClientPacket(org.bukkit.entity.Player sender, PacketContainer packet, boolean filters) throws java.lang.IllegalAccessException, java.lang.reflect.InvocationTargetException
Receiving a previously cancelled packet is discouraged. Use AsyncMarker.incrementProcessingDelay()
to delay a packet until a certain condition has been met.
recieveClientPacket
in interface PacketStream
sender
- - the sender.packet
- - the packet that was sent.filters
- - whether or not to invoke any packet filters below ListenerPriority.MONITOR
.java.lang.reflect.InvocationTargetException
- If the reflection machinery failed.java.lang.IllegalAccessException
- If the underlying method caused an error.void broadcastServerPacket(PacketContainer packet)
packet
- - the packet to broadcast.FieldAccessException
- If we were unable to send the packet due to reflection problems.void broadcastServerPacket(PacketContainer packet, org.bukkit.entity.Entity entity, boolean includeTracker)
This is usually every player in the same world within an observable distance. If the entity is a player, it will only be included if includeTracker is TRUE.
packet
- - the packet to broadcast.entity
- - the entity whose trackers we will inform.includeTracker
- - whether or not to also transmit the packet to the entity, if it is a tracker.FieldAccessException
- If we were unable to send the packet due to reflection problems.void broadcastServerPacket(PacketContainer packet, org.bukkit.Location origin, int maxObserverDistance)
packet
- - the packet to broadcast.origin
- - the origin to consider when calculating the distance to each observer.maxObserverDistance
- - the maximum distance to the origin.com.google.common.collect.ImmutableSet<PacketListener> getPacketListeners()
void addPacketListener(PacketListener listener)
Adding an already registered listener has no effect. If you need to change the packets the current listener is observing, you must first remove the packet listener before you can register it again.
listener
- - new packet listener.void removePacketListener(PacketListener listener)
Attempting to remove a listener that doesn't exist has no effect.
listener
- - the packet listener to remove.void removePacketListeners(org.bukkit.plugin.Plugin plugin)
plugin
- - the plugin to unload.@Deprecated PacketContainer createPacket(int id)
Deprecated: Use createPacket(PacketType)
instead.
id
- - packet ID.PacketContainer createPacket(PacketType type)
type
- - packet type.@Deprecated PacketContainer createPacket(int id, boolean forceDefaults)
If set to true, the forceDefaults option will force the system to automatically give non-primitive fields in the packet sensible default values. For instance, certain packets - like Packet60Explosion - require a List or Set to be non-null. If the forceDefaults option is true, the List or Set will be automatically created.
Deprecated: Use createPacket(PacketType, boolean)
instead.
id
- - packet ID.forceDefaults
- - TRUE to use sensible defaults in most fields, FALSE otherwise.PacketContainer createPacket(PacketType type, boolean forceDefaults)
If set to true, the forceDefaults option will force the system to automatically give non-primitive fields in the packet sensible default values. For instance, certain packets - like Packet60Explosion - require a List or Set to be non-null. If the forceDefaults option is true, the List or Set will be automatically created.
type
- - packet type.forceDefaults
- - TRUE to use sensible defaults in most fields, FALSE otherwise.@Deprecated PacketConstructor createPacketConstructor(int id, java.lang.Object... arguments)
Deprecated: Use createPacketConstructor(PacketType, Object...)
instead.
id
- - the packet ID.arguments
- - arguments that will be passed to the constructor.PacketConstructor createPacketConstructor(PacketType type, java.lang.Object... arguments)
id
- - the packet type.arguments
- - arguments that will be passed to the constructor.void updateEntity(org.bukkit.entity.Entity entity, java.util.List<org.bukkit.entity.Player> observers) throws FieldAccessException
Note that this method is NOT thread safe. If you call this method from anything but the main thread, it will throw an exception.
entity
- - entity to refresh.observers
- - the clients to update.FieldAccessException
org.bukkit.entity.Entity getEntityFromID(org.bukkit.World container, int id) throws FieldAccessException
container
- - the world the entity belongs to.id
- - the unique ID of the entity.FieldAccessException
- Reflection failed.java.util.List<org.bukkit.entity.Player> getEntityTrackers(org.bukkit.entity.Entity entity) throws FieldAccessException
entity
- - the entity that is being tracked.FieldAccessException
- If reflection failed.@Deprecated java.util.Set<java.lang.Integer> getSendingFilters()
Deprecated: Use getSendingFilterTypes()
instead.
java.util.Set<PacketType> getSendingFilterTypes()
@Deprecated java.util.Set<java.lang.Integer> getReceivingFilters()
Deprecated: Use getReceivingFilterTypes()
instead.
java.util.Set<PacketType> getReceivingFilterTypes()
MinecraftVersion getMinecraftVersion()
boolean isClosed()
AsynchronousManager getAsynchronousManager()