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 c1f15cc19..91d99ceea 100644 --- a/proxy/src/main/java/com/velocitypowered/proxy/connection/MinecraftConnection.java +++ b/proxy/src/main/java/com/velocitypowered/proxy/connection/MinecraftConnection.java @@ -124,6 +124,13 @@ public class MinecraftConnection extends ChannelInboundHandlerAdapter { } } + @Override + public void channelReadComplete(ChannelHandlerContext ctx) throws Exception { + if (sessionHandler != null) { + sessionHandler.readCompleted(); + } + } + @Override public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) throws Exception { if (ctx.channel().isActive()) { diff --git a/proxy/src/main/java/com/velocitypowered/proxy/connection/MinecraftSessionHandler.java b/proxy/src/main/java/com/velocitypowered/proxy/connection/MinecraftSessionHandler.java index 2789e17f9..297e5f884 100644 --- a/proxy/src/main/java/com/velocitypowered/proxy/connection/MinecraftSessionHandler.java +++ b/proxy/src/main/java/com/velocitypowered/proxy/connection/MinecraftSessionHandler.java @@ -70,6 +70,10 @@ public interface MinecraftSessionHandler { } + default void readCompleted() { + + } + default boolean handle(AvailableCommands commands) { return false; } diff --git a/proxy/src/main/java/com/velocitypowered/proxy/connection/backend/BackendPlaySessionHandler.java b/proxy/src/main/java/com/velocitypowered/proxy/connection/backend/BackendPlaySessionHandler.java index ba6678b78..aaa7e3c3a 100644 --- a/proxy/src/main/java/com/velocitypowered/proxy/connection/backend/BackendPlaySessionHandler.java +++ b/proxy/src/main/java/com/velocitypowered/proxy/connection/backend/BackendPlaySessionHandler.java @@ -168,12 +168,17 @@ public class BackendPlaySessionHandler implements MinecraftSessionHandler { if (packet instanceof PluginMessage) { ((PluginMessage) packet).retain(); } - playerConnection.write(packet); + playerConnection.delayedWrite(packet); } @Override public void handleUnknown(ByteBuf buf) { - playerConnection.write(buf.retain()); + playerConnection.delayedWrite(buf.retain()); + } + + @Override + public void readCompleted() { + playerConnection.flush(); } @Override