Interface ProtocolManager
- All Superinterfaces:
PacketStream
- All Known Subinterfaces:
InternalManager
- All Known Implementing Classes:
PacketFilterManager
-
Method Summary
Modifier and TypeMethodDescriptionvoidaddPacketListener(PacketListener listener) Adds a packet listener.voidbroadcastServerPacket(PacketContainer packet) Broadcast a given packet to every connected player on the server.voidbroadcastServerPacket(PacketContainer packet, Collection<? extends org.bukkit.entity.Player> targetPlayers) voidbroadcastServerPacket(PacketContainer packet, org.bukkit.entity.Entity entity, boolean includeTracker) Broadcast a packet to every player that is receiving information about a given entity.voidbroadcastServerPacket(PacketContainer packet, org.bukkit.Location origin, int maxObserverDistance) Broadcast a packet to every player within the given maximum observer distance.createPacket(PacketType type) Constructs a new encapsulated Minecraft packet with the given ID.createPacket(PacketType type, boolean forceDefaults) Constructs a new encapsulated Minecraft packet with the given ID.createPacketConstructor(PacketType type, Object... arguments) Construct a packet using the special builtin Minecraft constructors.Retrieve the current asynchronous packet manager.org.bukkit.entity.EntitygetEntityFromID(org.bukkit.World container, int id) Retrieve the associated entity.List<org.bukkit.entity.Player> getEntityTrackers(org.bukkit.entity.Entity entity) Retrieve every client that is receiving information about a given entity.Retrieve the current Minecraft version.com.google.common.collect.ImmutableSet<PacketListener> Retrieves a list of every registered packet listener.intgetProtocolVersion(org.bukkit.entity.Player player) Retrieve the protocol version of a given player.Retrieves a immutable set containing the type of the received client packets that will be observed by listeners.Retrieves a immutable set containing the type of the sent server packets that will be observed by listeners.booleanisClosed()Determines whether or not this protocol manager has been disabled.voidreceiveClientPacket(org.bukkit.entity.Player sender, PacketContainer packet, boolean filters) Simulate receiving a certain packet from a given player.voidremovePacketListener(PacketListener listener) Removes a given packet listener.voidremovePacketListeners(org.bukkit.plugin.Plugin plugin) Removes every listener associated with the given plugin.voidsendServerPacket(org.bukkit.entity.Player receiver, PacketContainer packet, boolean filters) Send a packet to the given player.voidupdateEntity(org.bukkit.entity.Entity entity, List<org.bukkit.entity.Player> observers) Completely resend an entity to a list of clients.voidverifyWhitelist(PacketListener listener, ListeningWhitelist whitelist) Methods inherited from interface com.comphenix.protocol.PacketStream
receiveClientPacket, receiveClientPacket, sendServerPacket, sendServerPacket, sendWirePacket, sendWirePacket
-
Method Details
-
getProtocolVersion
int getProtocolVersion(org.bukkit.entity.Player player) Retrieve the protocol version of a given player.This only really makes sense of a server that support clients of multiple Minecraft versions, such as Spigot #1628.
- Parameters:
player- - the player.- Returns:
- The associated protocol version, or
Integer.MIN_VALUEif unknown.
-
sendServerPacket
Send a packet to the given player.Re-sending a previously cancelled packet is discouraged. Use
AsyncMarker.incrementProcessingDelay()to delay a packet until a certain condition has been met.- Specified by:
sendServerPacketin interfacePacketStream- Parameters:
receiver- - the receiver.packet- - packet to send.filters- - whether or not to invoke any packet filters belowListenerPriority.MONITOR.
-
receiveClientPacket
Simulate receiving a certain packet from a given player.Receiving a previously cancelled packet is discouraged. Use
AsyncMarker.incrementProcessingDelay()to delay a packet until a certain condition has been met.- Specified by:
receiveClientPacketin interfacePacketStream- Parameters:
sender- - the sender.packet- - the packet that was sent.filters- - whether or not to invoke any packet filters belowListenerPriority.MONITOR.
-
broadcastServerPacket
Broadcast a given packet to every connected player on the server.- Parameters:
packet- - the packet to broadcast.- Throws:
FieldAccessException- If we were unable to send the packet due to reflection problems.
-
broadcastServerPacket
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.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.
- Parameters:
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.- Throws:
FieldAccessException- If we were unable to send the packet due to reflection problems.
-
broadcastServerPacket
void broadcastServerPacket(PacketContainer packet, org.bukkit.Location origin, int maxObserverDistance) Broadcast a packet to every player within the given maximum observer distance.- Parameters:
packet- - the packet to broadcast.origin- - the origin to consider when calculating the distance to each observer.maxObserverDistance- - the maximum distance to the origin.
-
broadcastServerPacket
void broadcastServerPacket(PacketContainer packet, Collection<? extends org.bukkit.entity.Player> targetPlayers) -
getPacketListeners
com.google.common.collect.ImmutableSet<PacketListener> getPacketListeners()Retrieves a list of every registered packet listener.- Returns:
- Every registered packet listener.
-
addPacketListener
Adds a packet 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.
- Parameters:
listener- - new packet listener.
-
removePacketListener
Removes a given packet listener.Attempting to remove a listener that doesn't exist has no effect.
- Parameters:
listener- - the packet listener to remove.
-
removePacketListeners
void removePacketListeners(org.bukkit.plugin.Plugin plugin) Removes every listener associated with the given plugin.- Parameters:
plugin- - the plugin to unload.
-
createPacket
Constructs a new encapsulated Minecraft packet with the given ID.- Parameters:
type- - packet type.- Returns:
- New encapsulated Minecraft packet.
-
createPacket
Constructs a new encapsulated Minecraft packet with the given ID.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.
- Parameters:
type- - packet type.forceDefaults- - TRUE to use sensible defaults in most fields, FALSE otherwise.- Returns:
- New encapsulated Minecraft packet.
-
createPacketConstructor
Construct a packet using the special builtin Minecraft constructors.- Parameters:
type- - the packet type.arguments- - arguments that will be passed to the constructor.- Returns:
- The packet constructor.
-
updateEntity
Completely resend an entity to a list of clients.Note that this method is NOT thread safe. If you call this method from anything but the main thread, it will throw an exception.
- Parameters:
entity- - entity to refresh.observers- - the clients to update.
-
getEntityFromID
org.bukkit.entity.Entity getEntityFromID(org.bukkit.World container, int id) Retrieve the associated entity.- Parameters:
container- - the world the entity belongs to.id- - the unique ID of the entity.- Returns:
- The associated entity.
- Throws:
FieldAccessException- Reflection failed.
-
getEntityTrackers
Retrieve every client that is receiving information about a given entity.- Parameters:
entity- - the entity that is being tracked.- Returns:
- Every client/player that is tracking the given entity.
- Throws:
FieldAccessException- If reflection failed.
-
getSendingFilterTypes
Set<PacketType> getSendingFilterTypes()Retrieves a immutable set containing the type of the sent server packets that will be observed by listeners.- Returns:
- Every filtered server packet.
-
getReceivingFilterTypes
Set<PacketType> getReceivingFilterTypes()Retrieves a immutable set containing the type of the received client packets that will be observed by listeners.- Returns:
- Every filtered client packet.
-
getMinecraftVersion
MinecraftVersion getMinecraftVersion()Retrieve the current Minecraft version.- Returns:
- The current version.
-
isClosed
boolean isClosed()Determines whether or not this protocol manager has been disabled.- Returns:
- TRUE if it has, FALSE otherwise.
-
getAsynchronousManager
AsynchronousManager getAsynchronousManager()Retrieve the current asynchronous packet manager.- Returns:
- Asynchronous packet manager.
-
verifyWhitelist
-