From e894a3c73355ea7e16c485d044cf8abd4a00a9bc Mon Sep 17 00:00:00 2001 From: Mats Date: Sat, 19 Mar 2016 21:53:26 +0100 Subject: [PATCH 1/2] Remove unnecessary if statement, this is always true. --- .../us/myles/ViaVersion/ViaVersionPlugin.java | 42 +++++++++---------- 1 file changed, 20 insertions(+), 22 deletions(-) diff --git a/src/main/java/us/myles/ViaVersion/ViaVersionPlugin.java b/src/main/java/us/myles/ViaVersion/ViaVersionPlugin.java index 8e27b6895..5cdbc3796 100644 --- a/src/main/java/us/myles/ViaVersion/ViaVersionPlugin.java +++ b/src/main/java/us/myles/ViaVersion/ViaVersionPlugin.java @@ -136,33 +136,31 @@ public class ViaVersionPlugin extends JavaPlugin implements ViaVersionAPI { getLogger().warning("We failed to find the ServerConnection? :( What server are you running?"); return; } - if (connection != null) { - for (Field field : connection.getClass().getDeclaredFields()) { - field.setAccessible(true); - final Object value = field.get(connection); - if (value instanceof List) { - // Inject the list - List wrapper = new ListWrapper((List) value) { - @Override - public synchronized void handleAdd(Object o) { - synchronized (this) { - if (o instanceof ChannelFuture) { - inject((ChannelFuture) o); - } - } - } - }; - field.set(connection, wrapper); - // Iterate through current list - synchronized (wrapper) { - for (Object o : (List) value) { + for (Field field : connection.getClass().getDeclaredFields()) { + field.setAccessible(true); + final Object value = field.get(connection); + if (value instanceof List) { + // Inject the list + List wrapper = new ListWrapper((List) value) { + @Override + public synchronized void handleAdd(Object o) { + synchronized (this) { if (o instanceof ChannelFuture) { inject((ChannelFuture) o); - } else { - break; // not the right list. } } } + }; + field.set(connection, wrapper); + // Iterate through current list + synchronized (wrapper) { + for (Object o : (List) value) { + if (o instanceof ChannelFuture) { + inject((ChannelFuture) o); + } else { + break; // not the right list. + } + } } } } From 1fbd561aec4d3ffef19253ef1f10e62228e4259d Mon Sep 17 00:00:00 2001 From: Myles Date: Sat, 19 Mar 2016 22:04:17 +0000 Subject: [PATCH 2/2] Oops, fix 1.8 clients --- .../java/us/myles/ViaVersion/handlers/ViaDecodeHandler.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/main/java/us/myles/ViaVersion/handlers/ViaDecodeHandler.java b/src/main/java/us/myles/ViaVersion/handlers/ViaDecodeHandler.java index c4483c2d2..c28dc4e57 100644 --- a/src/main/java/us/myles/ViaVersion/handlers/ViaDecodeHandler.java +++ b/src/main/java/us/myles/ViaVersion/handlers/ViaDecodeHandler.java @@ -48,7 +48,9 @@ public class ViaDecodeHandler extends ByteToMessageDecoder { throw (Exception) e.getCause(); } } finally { - bytebuf.release(); + if (info.isActive()) { + bytebuf.release(); + } } } }