buf.markReaderIndex();
opcode = ByteBufUtils.readVarInt(buf);
return inboundCodecs.find(opcode);
} catch (IOException e) {
throw new UnknownPacketException("Failed to read packet data (corrupt?)", opcode, length);
} catch (IllegalOpcodeException e) {
// go back to before opcode, so that skipping length doesn't skip too much
buf.resetReaderIndex();
throw new UnknownPacketException("Opcode received is not a registered codec on the server!", opcode, length);
}
}