From 6eb6c99fa7afa30325f6f42c0727f47775faad40 Mon Sep 17 00:00:00 2001 From: Andrew Steinborn Date: Sun, 27 Jan 2019 22:57:40 -0500 Subject: [PATCH] Simplify MinecraftConnection release logic. --- .../proxy/connection/MinecraftConnection.java | 31 +++++++------------ 1 file changed, 12 insertions(+), 19 deletions(-) diff --git a/proxy/src/main/java/com/velocitypowered/proxy/connection/MinecraftConnection.java b/proxy/src/main/java/com/velocitypowered/proxy/connection/MinecraftConnection.java index be92e54f2..62a5e98c4 100644 --- a/proxy/src/main/java/com/velocitypowered/proxy/connection/MinecraftConnection.java +++ b/proxy/src/main/java/com/velocitypowered/proxy/connection/MinecraftConnection.java @@ -102,32 +102,25 @@ public class MinecraftConnection extends ChannelInboundHandlerAdapter { return; } - if (msg instanceof MinecraftPacket) { + try { if (sessionHandler.beforeHandle()) { return; } - MinecraftPacket pkt = (MinecraftPacket) msg; - if (!pkt.handle(sessionHandler)) { - sessionHandler.handleGeneric((MinecraftPacket) msg); - } - } else if (msg instanceof HAProxyMessage) { - if (sessionHandler.beforeHandle()) { - return; - } - - HAProxyMessage proxyMessage = (HAProxyMessage) msg; - this.remoteAddress = new InetSocketAddress(proxyMessage.sourceAddress(), - proxyMessage.sourcePort()); - } else if (msg instanceof ByteBuf) { - try { - if (sessionHandler.beforeHandle()) { - return; + if (msg instanceof MinecraftPacket) { + MinecraftPacket pkt = (MinecraftPacket) msg; + if (!pkt.handle(sessionHandler)) { + sessionHandler.handleGeneric((MinecraftPacket) msg); } + } else if (msg instanceof HAProxyMessage) { + HAProxyMessage proxyMessage = (HAProxyMessage) msg; + this.remoteAddress = new InetSocketAddress(proxyMessage.sourceAddress(), + proxyMessage.sourcePort()); + } else if (msg instanceof ByteBuf) { sessionHandler.handleUnknown((ByteBuf) msg); - } finally { - ReferenceCountUtil.release(msg); } + } finally { + ReferenceCountUtil.release(msg); } }