package net.sf.l2j.gameserver; import java.nio.ByteBuffer; import net.sf.l2j.gameserver.clientpackets.ClientBasePacket; /** * This interface can be implemented by custom extensions to l2j to get packets * before the normal processing of PacketHandler * * @version $Revision: $ $Date: $ * @author galun */ public interface CustomPacketHandlerInterface { /** * interface for a custom packethandler to ckeck received packets * PacketHandler will take care of the packet if this function returns null. * @param data the packet * @param client the ClientThread * @return a ClientBasePacket if the packet has been processed, null otherwise */ public ClientBasePacket handlePacket(ByteBuffer data, ClientThread client); } Index: /home/jru199/trunk/L2_GameServer_c4/java/net/sf/l2j/gameserver/PacketHandler.java =================================================================== --- /home/jru199/trunk/L2_GameServer_c4/java/net/sf/l2j/gameserver/PacketHandler.java (revision 1898) +++ /home/jru199/trunk/L2_GameServer_c4/java/net/sf/l2j/gameserver/PacketHandler.java (working copy) @@ -19,6 +19,7 @@ package net.sf.l2j.gameserver; import java.nio.ByteBuffer; +import java.util.LinkedList; import java.util.logging.Logger; import net.sf.l2j.Config; @@ -34,6 +35,7 @@ public class PacketHandler { private static Logger _log = Logger.getLogger(PacketHandler.class.getName()); + private static LinkedList customhandlers = new LinkedList(); private PacketHandler() { @@ -39,7 +41,14 @@ { } - + public static void addCustomHandler(CustomPacketHandlerInterface handler) { + customhandlers.add(handler); + } + + public static void removeCustomHandler(CustomPacketHandlerInterface handler) { + customhandlers.remove(handler); + } + public static ClientBasePacket handlePacket(ByteBuffer data, ClientThread client) { ClientBasePacket msg = null; @@ -44,7 +53,14 @@ { ClientBasePacket msg = null; int id = data.get() & 0xff; - + + for (CustomPacketHandlerInterface handler : customhandlers) { + msg = handler.handlePacket(data, client); + if (msg != null) + break; + } + + if (msg == null) switch(id) { case 0x00: