public interface ProtocolManager extends PacketStream
Modifier and Type | Method and Description |
---|---|
void |
addPacketListener(PacketListener listener)
Adds a packet listener.
|
PacketContainer |
createPacket(int id)
Constructs a new encapsulated Minecraft packet with the given ID.
|
PacketContainer |
createPacket(int id,
boolean forceDefaults)
Constructs a new encapsulated Minecraft packet with the given ID.
|
PacketConstructor |
createPacketConstructor(int id,
java.lang.Object... arguments)
Construct a packet using the special builtin Minecraft constructors.
|
AsynchronousManager |
getAsynchronousManager()
Retrieve the current asyncronous packet manager.
|
Entity |
getEntityFromID(World container,
int id)
Retrieve the associated entity.
|
java.util.List<Player> |
getEntityTrackers(Entity entity)
Retrieve every client that is receiving information about a given entity.
|
com.google.common.collect.ImmutableSet<PacketListener> |
getPacketListeners()
Retrieves a list of every registered packet listener.
|
java.util.Set<java.lang.Integer> |
getReceivingFilters()
Retrieves a immutable set containing the ID of the recieved client packets that will be observed by listeners.
|
java.util.Set<java.lang.Integer> |
getSendingFilters()
Retrieves a immutable set containing the ID of the sent server packets that will be observed by listeners.
|
boolean |
isClosed()
Determines whether or not this protocol mananger has been disabled.
|
void |
recieveClientPacket(Player sender,
PacketContainer packet,
boolean filters)
Simulate recieving a certain packet from a given player.
|
void |
removePacketListener(PacketListener listener)
Removes a given packet listener.
|
void |
removePacketListeners(Plugin plugin)
Removes every listener associated with the given plugin.
|
void |
sendServerPacket(Player reciever,
PacketContainer packet,
boolean filters)
Send a packet to the given player.
|
void |
updateEntity(Entity entity,
java.util.List<Player> observers)
Completely resend an entity to a list of clients.
|
recieveClientPacket, sendServerPacket
void sendServerPacket(Player reciever, PacketContainer packet, boolean filters) throws java.lang.reflect.InvocationTargetException
Re-sending a previously cancelled packet is discuraged. Use AsyncMarker.incrementProcessingDelay()
to delay a packet until a certain condition has been met.
sendServerPacket
in interface PacketStream
reciever
- - the reciever.packet
- - packet to send.filters
- - whether or not to invoke any packet filters.java.lang.reflect.InvocationTargetException
- - if an error occured when sending the packet.void recieveClientPacket(Player sender, PacketContainer packet, boolean filters) throws java.lang.IllegalAccessException, java.lang.reflect.InvocationTargetException
Receiving a previously cancelled packet is discuraged. 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.java.lang.reflect.InvocationTargetException
- If the reflection machinery failed.java.lang.IllegalAccessException
- If the underlying method caused an error.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(Plugin plugin)
plugin
- - the plugin to unload.PacketContainer createPacket(int id)
id
- - packet ID.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.
id
- - packet ID.forceDefaults
- - TRUE to use sensible defaults in most fields, FALSE otherwise.PacketConstructor createPacketConstructor(int id, java.lang.Object... arguments)
id
- - the packet ID.arguments
- - arguments that will be passed to the constructor.void updateEntity(Entity entity, java.util.List<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
Entity getEntityFromID(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<Player> getEntityTrackers(Entity entity) throws FieldAccessException
entity
- - the entity that is being tracked.FieldAccessException
- If reflection failed.java.util.Set<java.lang.Integer> getSendingFilters()
java.util.Set<java.lang.Integer> getReceivingFilters()
boolean isClosed()
AsynchronousManager getAsynchronousManager()