Remove useless if

This commit is contained in:
CharlesVaneenoo
2016-03-15 20:01:00 +01:00
parent 7cc39b1685
commit fc5b8d7b0b
@@ -31,14 +31,11 @@ public final class GamePacketEncoder extends MessageToByteEncoder<GamePacket> {
protected void encode(ChannelHandlerContext ctx, GamePacket packet, ByteBuf out) throws Exception {
PacketType type = packet.getType();
int payloadLength = packet.getLength();
if (type == PacketType.VARIABLE_BYTE) {
if (payloadLength >= 256) {
throw new Exception("Payload too long for variable byte packet.");
}
} else if (type == PacketType.VARIABLE_SHORT) {
if (payloadLength >= 65_536) {
throw new Exception("Payload too long for variable short packet.");
}
if (type == PacketType.VARIABLE_BYTE && payloadLength >= 256) {
throw new Exception("Payload too long for variable byte packet.");
} else if (type == PacketType.VARIABLE_SHORT && payloadLength >= 65_536) {
throw new Exception("Payload too long for variable short packet.");
}
out.writeByte(packet.getOpcode() + random.nextInt() & 0xFF);