diff --git a/src/main/java/us/myles/ViaVersion/ViaVersionPlugin.java b/src/main/java/us/myles/ViaVersion/ViaVersionPlugin.java index efa05b282..d49792f68 100644 --- a/src/main/java/us/myles/ViaVersion/ViaVersionPlugin.java +++ b/src/main/java/us/myles/ViaVersion/ViaVersionPlugin.java @@ -181,33 +181,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. + } + } } } } diff --git a/src/main/java/us/myles/ViaVersion/handlers/ViaDecodeHandler.java b/src/main/java/us/myles/ViaVersion/handlers/ViaDecodeHandler.java index 58b23889a..ee275e130 100644 --- a/src/main/java/us/myles/ViaVersion/handlers/ViaDecodeHandler.java +++ b/src/main/java/us/myles/ViaVersion/handlers/ViaDecodeHandler.java @@ -54,7 +54,9 @@ public class ViaDecodeHandler extends ByteToMessageDecoder { throw (Exception) e.getCause(); } } finally { - bytebuf.release(); + if (info.isActive()) { + bytebuf.release(); + } } } }