From fc5b8d7b0b40e83239ab162fa4cf254fe4a2bb4c Mon Sep 17 00:00:00 2001 From: CharlesVaneenoo Date: Tue, 15 Mar 2016 20:01:00 +0100 Subject: [PATCH] Remove useless if --- .../apollo/net/codec/game/GamePacketEncoder.java | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/net/src/main/org/apollo/net/codec/game/GamePacketEncoder.java b/net/src/main/org/apollo/net/codec/game/GamePacketEncoder.java index 508cbb1f..0a9bfa1e 100644 --- a/net/src/main/org/apollo/net/codec/game/GamePacketEncoder.java +++ b/net/src/main/org/apollo/net/codec/game/GamePacketEncoder.java @@ -31,14 +31,11 @@ public final class GamePacketEncoder extends MessageToByteEncoder { 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);