@@ -263,16 +275,16 @@ abstract class PlayerInjector { * @param packet - packet to recieve. * @return The given packet, or the packet replaced by the listeners. */ - Packet handlePacketRecieved(Packet packet) { + public Packet handlePacketRecieved(Packet packet) { // Get the packet ID too - Integer id = MinecraftRegistry.getPacketToID().get(packet.getClass()); + Integer id = invoker.getPacketID(packet); // Make sure we're listening - if (id != null && sendingFilters.contains(id)) { + if (id != null && hasListener(id)) { // A packet has been sent guys! PacketContainer container = new PacketContainer(id, packet); - PacketEvent event = PacketEvent.fromServer(manager, container, player); - manager.invokePacketSending(event); + PacketEvent event = PacketEvent.fromServer(invoker, container, player); + invoker.invokePacketSending(event); // Cancelling is pretty simple. Just ignore the packet. if (event.isCancelled()) @@ -285,6 +297,13 @@ abstract class PlayerInjector { return packet; } + /** + * Determine if the given injector is listening for this packet ID. + * @param packetID - packet ID to check. + * @return TRUE if it is, FALSE oterhwise. + */ + protected abstract boolean hasListener(int packetID); + /** * Retrieve the current player's input stream. * @param cache - whether or not to cache the result of this method. diff --git a/ProtocolLib/src/com/comphenix/protocol/injector/ReplacedArrayList.java b/ProtocolLib/src/com/comphenix/protocol/injector/player/ReplacedArrayList.java similarity index 94% rename from ProtocolLib/src/com/comphenix/protocol/injector/ReplacedArrayList.java rename to ProtocolLib/src/com/comphenix/protocol/injector/player/ReplacedArrayList.java index 2923785c..ed239f3c 100644 --- a/ProtocolLib/src/com/comphenix/protocol/injector/ReplacedArrayList.java +++ b/ProtocolLib/src/com/comphenix/protocol/injector/player/ReplacedArrayList.java @@ -1,4 +1,4 @@ -package com.comphenix.protocol.injector; +package com.comphenix.protocol.injector.player; import java.util.Collection; import java.util.List;