public final class PacketFilterManager extends java.lang.Object implements ProtocolManager, ListenerInvoker, InternalManager
| Modifier and Type | Class and Description |
|---|---|
static class |
PacketFilterManager.PlayerInjectHooks
Sets the inject hook type.
|
| Modifier and Type | Field and Description |
|---|---|
static ReportType |
REPORT_CANNOT_INITIALIZE_PACKET_INJECTOR |
static ReportType |
REPORT_CANNOT_INJECT_PLAYER |
static ReportType |
REPORT_CANNOT_LOAD_PACKET_LIST |
static ReportType |
REPORT_CANNOT_UNINJECT_OFFLINE_PLAYER |
static ReportType |
REPORT_CANNOT_UNINJECT_PLAYER |
static ReportType |
REPORT_CANNOT_UNREGISTER_PLUGIN |
static ReportType |
REPORT_PLUGIN_DEPEND_MISSING |
static ReportType |
REPORT_PLUGIN_VERIFIER_ERROR |
static ReportType |
REPORT_UNSUPPORTED_CLIENT_PACKET_ID |
static ReportType |
REPORT_UNSUPPORTED_SERVER_PACKET_ID |
static int |
TICKS_PER_SECOND
The number of ticks in a second.
|
| Constructor and Description |
|---|
PacketFilterManager(PacketFilterBuilder builder)
Only create instances of this class if protocol lib is disabled.
|
| 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.
|
void |
close()
Called when ProtocolLib is closing.
|
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.
|
protected void |
finalize() |
AsynchronousManager |
getAsynchronousManager()
Retrieve the current asynchronous packet manager.
|
java.lang.ClassLoader |
getClassLoader()
Retrieves the current plugin class loader.
|
static java.util.Set<java.lang.Integer> |
getClientPackets()
Deprecated.
|
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.
|
com.comphenix.protocol.injector.packet.InterceptWritePacket |
getInterceptWritePacket()
Retrieve the object responsible for intercepting write packets.
|
MinecraftVersion |
getMinecraftVersion()
Retrieve the current Minecraft version.
|
java.lang.Class<?> |
getPacketClassFromID(int packetID,
boolean forceVanilla)
Deprecated.
|
int |
getPacketID(java.lang.Object packet)
Deprecated.
|
com.google.common.collect.ImmutableSet<PacketListener> |
getPacketListeners()
Retrieves a list of every registered packet listener.
|
PacketType |
getPacketType(java.lang.Object packet)
Retrieve the associated type of a packet.
|
PacketFilterManager.PlayerInjectHooks |
getPlayerHook()
Retrieves how the server packets are read.
|
java.util.Set<java.lang.Integer> |
getReceivingFilters()
Retrieves a immutable set containing the ID of the received client packets that will be observed by listeners.
|
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.
|
static java.util.Set<java.lang.Integer> |
getServerPackets()
Deprecated.
|
void |
initializePlayers(org.bukkit.entity.Player[] players)
Initialize the packet injection for every player.
|
void |
invokePacketRecieving(PacketEvent event)
Invokes the given packet event for every registered listener.
|
void |
invokePacketSending(PacketEvent event)
Invokes the given packet event for every registered listener.
|
boolean |
isClosed()
Determines whether or not this protocol manager has been disabled.
|
boolean |
isDebug()
Determine if debug mode is enabled.
|
static PacketFilterBuilder |
newBuilder()
Construct a new packet filter builder.
|
void |
recieveClientPacket(org.bukkit.entity.Player sender,
PacketContainer packet)
Simulate recieving a certain packet from a given player.
|
void |
recieveClientPacket(org.bukkit.entity.Player sender,
PacketContainer packet,
boolean filters)
Simulate receiving a certain packet from a given player.
|
void |
recieveClientPacket(org.bukkit.entity.Player sender,
PacketContainer packet,
NetworkMarker marker,
boolean filters)
Simulate recieving a certain packet from a given player.
|
void |
registerEvents(org.bukkit.plugin.PluginManager manager,
org.bukkit.plugin.Plugin plugin)
Register this protocol manager on Bukkit.
|
void |
registerPacketClass(java.lang.Class<?> clazz,
int packetID)
Deprecated.
|
void |
removePacketListener(PacketListener listener)
Removes a given packet listener.
|
void |
removePacketListeners(org.bukkit.plugin.Plugin plugin)
Removes every listener associated with the given plugin.
|
boolean |
requireInputBuffer(int packetId)
Determine if a given packet requires input buffering.
|
void |
sendServerPacket(org.bukkit.entity.Player reciever,
PacketContainer packet)
Send a packet to the given player.
|
void |
sendServerPacket(org.bukkit.entity.Player reciever,
PacketContainer packet,
boolean filters)
Send a packet to the given player.
|
void |
sendServerPacket(org.bukkit.entity.Player receiver,
PacketContainer packet,
NetworkMarker marker,
boolean filters)
Send a packet to the given player.
|
void |
setDebug(boolean debug)
Set whether or not debug mode is enabled.
|
void |
setPlayerHook(PacketFilterManager.PlayerInjectHooks playerHook)
Sets how the server packets are read.
|
void |
uninitializePlayers(org.bukkit.entity.Player[] players)
Uninitialize the packet injection of every player.
|
void |
unregisterPacketClass(java.lang.Class<?> clazz)
Deprecated.
|
void |
updateEntity(org.bukkit.entity.Entity entity,
java.util.List<org.bukkit.entity.Player> observers)
Completely resend an entity to a list of clients.
|
static void |
verifyWhitelist(PacketListener listener,
ListeningWhitelist whitelist)
Determine if the packet IDs in a whitelist is valid.
|
public static final ReportType REPORT_CANNOT_LOAD_PACKET_LIST
public static final ReportType REPORT_CANNOT_INITIALIZE_PACKET_INJECTOR
public static final ReportType REPORT_PLUGIN_DEPEND_MISSING
public static final ReportType REPORT_UNSUPPORTED_SERVER_PACKET_ID
public static final ReportType REPORT_UNSUPPORTED_CLIENT_PACKET_ID
public static final ReportType REPORT_CANNOT_UNINJECT_PLAYER
public static final ReportType REPORT_CANNOT_UNINJECT_OFFLINE_PLAYER
public static final ReportType REPORT_CANNOT_INJECT_PLAYER
public static final ReportType REPORT_CANNOT_UNREGISTER_PLUGIN
public static final ReportType REPORT_PLUGIN_VERIFIER_ERROR
public static final int TICKS_PER_SECOND
public PacketFilterManager(PacketFilterBuilder builder)
public static PacketFilterBuilder newBuilder()
public MinecraftVersion getMinecraftVersion()
ProtocolManagergetMinecraftVersion in interface ProtocolManagerpublic AsynchronousManager getAsynchronousManager()
ProtocolManagergetAsynchronousManager in interface ProtocolManagerpublic boolean isDebug()
InternalManagerisDebug in interface InternalManagerpublic void setDebug(boolean debug)
InternalManagersetDebug in interface InternalManagerdebug - - TRUE if it is, FALSE otherwise.public PacketFilterManager.PlayerInjectHooks getPlayerHook()
getPlayerHook in interface InternalManagerpublic void setPlayerHook(PacketFilterManager.PlayerInjectHooks playerHook)
setPlayerHook in interface InternalManagerplayerHook - - the new injection method for reading server packets.public com.google.common.collect.ImmutableSet<PacketListener> getPacketListeners()
ProtocolManagergetPacketListeners in interface ProtocolManagerpublic com.comphenix.protocol.injector.packet.InterceptWritePacket getInterceptWritePacket()
ListenerInvokergetInterceptWritePacket in interface ListenerInvokerpublic void addPacketListener(PacketListener listener)
ProtocolManagerAdding 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.
addPacketListener in interface ProtocolManagerlistener - - new packet listener.public static void verifyWhitelist(PacketListener listener, ListeningWhitelist whitelist)
listener - - the listener that will be mentioned in the error.whitelist - - whitelist of packet IDs.java.lang.IllegalArgumentException - If the whitelist is illegal.public void removePacketListener(PacketListener listener)
ProtocolManagerAttempting to remove a listener that doesn't exist has no effect.
removePacketListener in interface ProtocolManagerlistener - - the packet listener to remove.public void removePacketListeners(org.bukkit.plugin.Plugin plugin)
ProtocolManagerremovePacketListeners in interface ProtocolManagerplugin - - the plugin to unload.public void invokePacketRecieving(PacketEvent event)
ListenerInvokerinvokePacketRecieving in interface ListenerInvokerevent - - the packet event to invoke.public void invokePacketSending(PacketEvent event)
ListenerInvokerinvokePacketSending in interface ListenerInvokerevent - - the packet event to invoke.public boolean requireInputBuffer(int packetId)
ListenerInvokerrequireInputBuffer in interface ListenerInvokerpacketId - - the packet to check.public void broadcastServerPacket(PacketContainer packet)
ProtocolManagerbroadcastServerPacket in interface ProtocolManagerpacket - - the packet to broadcast.public void broadcastServerPacket(PacketContainer packet, org.bukkit.entity.Entity entity, boolean includeTracker)
ProtocolManagerThis 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.
broadcastServerPacket in interface ProtocolManagerpacket - - 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.public void broadcastServerPacket(PacketContainer packet, org.bukkit.Location origin, int maxObserverDistance)
ProtocolManagerbroadcastServerPacket in interface ProtocolManagerpacket - - the packet to broadcast.origin - - the origin to consider when calculating the distance to each observer.maxObserverDistance - - the maximum distance to the origin.public void sendServerPacket(org.bukkit.entity.Player reciever,
PacketContainer packet)
throws java.lang.reflect.InvocationTargetException
PacketStreamsendServerPacket in interface PacketStreamreciever - - the reciever.packet - - packet to send.java.lang.reflect.InvocationTargetException - - if an error occured when sending the packet.public void sendServerPacket(org.bukkit.entity.Player reciever,
PacketContainer packet,
boolean filters)
throws java.lang.reflect.InvocationTargetException
ProtocolManager
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 PacketStreamsendServerPacket in interface ProtocolManagerreciever - - 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.public void sendServerPacket(org.bukkit.entity.Player receiver,
PacketContainer packet,
NetworkMarker marker,
boolean filters)
throws java.lang.reflect.InvocationTargetException
PacketStreamsendServerPacket in interface PacketStreamreceiver - - the receiver.packet - - packet to send.marker - - the network marker to use.filters - - whether or not to invoke any packet filters below ListenerPriority.MONITOR.java.lang.reflect.InvocationTargetException - - if an error occured when sending the packet.public void recieveClientPacket(org.bukkit.entity.Player sender,
PacketContainer packet)
throws java.lang.IllegalAccessException,
java.lang.reflect.InvocationTargetException
PacketStreamrecieveClientPacket in interface PacketStreamsender - - the sender.packet - - the packet that was sent.java.lang.IllegalAccessException - If the underlying method caused an error.java.lang.reflect.InvocationTargetException - If the reflection machinery failed.public void recieveClientPacket(org.bukkit.entity.Player sender,
PacketContainer packet,
boolean filters)
throws java.lang.IllegalAccessException,
java.lang.reflect.InvocationTargetException
ProtocolManager
Receiving a previously cancelled packet is discouraged. Use AsyncMarker.incrementProcessingDelay()
to delay a packet until a certain condition has been met.
recieveClientPacket in interface PacketStreamrecieveClientPacket in interface ProtocolManagersender - - the sender.packet - - the packet that was sent.filters - - whether or not to invoke any packet filters below ListenerPriority.MONITOR.java.lang.IllegalAccessException - If the underlying method caused an error.java.lang.reflect.InvocationTargetException - If the reflection machinery failed.public void recieveClientPacket(org.bukkit.entity.Player sender,
PacketContainer packet,
NetworkMarker marker,
boolean filters)
throws java.lang.IllegalAccessException,
java.lang.reflect.InvocationTargetException
PacketStreamrecieveClientPacket in interface PacketStreamsender - - the sender.packet - - the packet that was sent.marker - - the network marker to use.filters - - whether or not to invoke any packet filters below ListenerPriority.MONITOR.java.lang.IllegalAccessException - If the underlying method caused an error.java.lang.reflect.InvocationTargetException - If the reflection machinery failed.@Deprecated public PacketContainer createPacket(int id)
ProtocolManager
Deprecated: Use ProtocolManager.createPacket(PacketType) instead.
createPacket in interface ProtocolManagerid - - packet ID.public PacketContainer createPacket(PacketType type)
ProtocolManagercreatePacket in interface ProtocolManagertype - - packet type.@Deprecated public PacketContainer createPacket(int id, boolean forceDefaults)
ProtocolManagerIf 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 ProtocolManager.createPacket(PacketType, boolean) instead.
createPacket in interface ProtocolManagerid - - packet ID.forceDefaults - - TRUE to use sensible defaults in most fields, FALSE otherwise.public PacketContainer createPacket(PacketType type, boolean forceDefaults)
ProtocolManagerIf 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.
createPacket in interface ProtocolManagertype - - packet type.forceDefaults - - TRUE to use sensible defaults in most fields, FALSE otherwise.@Deprecated public PacketConstructor createPacketConstructor(int id, java.lang.Object... arguments)
ProtocolManager
Deprecated: Use ProtocolManager.createPacketConstructor(PacketType, Object...) instead.
createPacketConstructor in interface ProtocolManagerid - - the packet ID.arguments - - arguments that will be passed to the constructor.public PacketConstructor createPacketConstructor(PacketType type, java.lang.Object... arguments)
ProtocolManagercreatePacketConstructor in interface ProtocolManagerarguments - - arguments that will be passed to the constructor.@Deprecated public java.util.Set<java.lang.Integer> getSendingFilters()
ProtocolManager
Deprecated: Use ProtocolManager.getSendingFilterTypes() instead.
getSendingFilters in interface ProtocolManagerpublic java.util.Set<java.lang.Integer> getReceivingFilters()
ProtocolManager
Deprecated: Use ProtocolManager.getReceivingFilterTypes() instead.
getReceivingFilters in interface ProtocolManagerpublic java.util.Set<PacketType> getSendingFilterTypes()
ProtocolManagergetSendingFilterTypes in interface ProtocolManagerpublic java.util.Set<PacketType> getReceivingFilterTypes()
ProtocolManagergetReceivingFilterTypes in interface ProtocolManagerpublic void updateEntity(org.bukkit.entity.Entity entity,
java.util.List<org.bukkit.entity.Player> observers)
throws FieldAccessException
ProtocolManagerNote that this method is NOT thread safe. If you call this method from anything but the main thread, it will throw an exception.
updateEntity in interface ProtocolManagerentity - - entity to refresh.observers - - the clients to update.FieldAccessExceptionpublic org.bukkit.entity.Entity getEntityFromID(org.bukkit.World container,
int id)
throws FieldAccessException
ProtocolManagergetEntityFromID in interface ProtocolManagercontainer - - the world the entity belongs to.id - - the unique ID of the entity.FieldAccessException - Reflection failed.public java.util.List<org.bukkit.entity.Player> getEntityTrackers(org.bukkit.entity.Entity entity)
throws FieldAccessException
ProtocolManagergetEntityTrackers in interface ProtocolManagerentity - - the entity that is being tracked.FieldAccessException - If reflection failed.public void initializePlayers(org.bukkit.entity.Player[] players)
players - - list of players to inject.public void uninitializePlayers(org.bukkit.entity.Player[] players)
players - - list of players to uninject.public void registerEvents(org.bukkit.plugin.PluginManager manager,
org.bukkit.plugin.Plugin plugin)
registerEvents in interface InternalManagermanager - - Bukkit plugin manager that provides player join/leave events.plugin - - the parent plugin.@Deprecated public int getPacketID(java.lang.Object packet)
ListenerInvokergetPacketID in interface ListenerInvokerpacket - - the packet.public PacketType getPacketType(java.lang.Object packet)
ListenerInvokergetPacketType in interface ListenerInvokerpacket - - the packet.@Deprecated
public void registerPacketClass(java.lang.Class<?> clazz,
int packetID)
ListenerInvokerregisterPacketClass in interface ListenerInvokerclazz - - class to register.packetID - - the the new associated packet ID.@Deprecated public void unregisterPacketClass(java.lang.Class<?> clazz)
ListenerInvokerunregisterPacketClass in interface ListenerInvokerclazz - - class to associate.@Deprecated
public java.lang.Class<?> getPacketClassFromID(int packetID,
boolean forceVanilla)
ListenerInvokergetPacketClassFromID in interface ListenerInvokerpacketID - - the packet ID.forceVanilla - - whether or not to look for vanilla classes, not injected classes.@Deprecated
public static java.util.Set<java.lang.Integer> getServerPackets()
throws FieldAccessException
FieldAccessException - If we're unable to retrieve the server packet data from Minecraft.@Deprecated
public static java.util.Set<java.lang.Integer> getClientPackets()
throws FieldAccessException
FieldAccessException - If we're unable to retrieve the client packet data from Minecraft.public java.lang.ClassLoader getClassLoader()
public boolean isClosed()
ProtocolManagerisClosed in interface ProtocolManagerpublic void close()
InternalManagerclose in interface InternalManagerprotected void finalize()
throws java.lang.Throwable
finalize in class java.lang.Objectjava.lang.Throwable