private PacketProcessor() { int maxRecvOp = 0; for (RecvPacketOpcode op : RecvPacketOpcode.values()) { if (op.getValue() > maxRecvOp) { maxRecvOp = op.getValue(); } } this.handlers = new MaplePacketHandler[maxRecvOp + 1]; }
public void registerHandler(RecvPacketOpcode code, MaplePacketHandler handler) { try { this.handlers[code.getValue()] = handler; } catch (ArrayIndexOutOfBoundsException e) { System.out.println("Error while registering handler - " + handler.toString()); } }