From 6c3479e7393f138bbc3b0e31ebd2395296a68627 Mon Sep 17 00:00:00 2001 From: creeper123123321 <7974274+creeper123123321@users.noreply.github.com> Date: Tue, 30 Jun 2020 16:06:05 -0300 Subject: [PATCH] rebased on master --- .../us/myles/ViaVersion/VelocityPlugin.java | 6 +---- .../handlers/VelocityDecodeHandler.java | 8 +++--- .../handlers/VelocityEncodeHandler.java | 2 +- .../platform/VelocityConnectionManager.java | 26 ++----------------- 4 files changed, 8 insertions(+), 34 deletions(-) diff --git a/velocity/src/main/java/us/myles/ViaVersion/VelocityPlugin.java b/velocity/src/main/java/us/myles/ViaVersion/VelocityPlugin.java index f68adbbde..2321aeb00 100644 --- a/velocity/src/main/java/us/myles/ViaVersion/VelocityPlugin.java +++ b/velocity/src/main/java/us/myles/ViaVersion/VelocityPlugin.java @@ -26,11 +26,7 @@ import us.myles.ViaVersion.util.GsonUtil; import us.myles.ViaVersion.velocity.VersionInfo; import us.myles.ViaVersion.velocity.command.VelocityCommandHandler; import us.myles.ViaVersion.velocity.command.VelocityCommandSender; -import us.myles.ViaVersion.velocity.platform.VelocityTaskId; -import us.myles.ViaVersion.velocity.platform.VelocityViaAPI; -import us.myles.ViaVersion.velocity.platform.VelocityViaConfig; -import us.myles.ViaVersion.velocity.platform.VelocityViaInjector; -import us.myles.ViaVersion.velocity.platform.VelocityViaLoader; +import us.myles.ViaVersion.velocity.platform.*; import us.myles.ViaVersion.velocity.service.ProtocolDetectorService; import us.myles.ViaVersion.velocity.util.LoggerWrapper; diff --git a/velocity/src/main/java/us/myles/ViaVersion/velocity/handlers/VelocityDecodeHandler.java b/velocity/src/main/java/us/myles/ViaVersion/velocity/handlers/VelocityDecodeHandler.java index 85af37c16..4981c2954 100644 --- a/velocity/src/main/java/us/myles/ViaVersion/velocity/handlers/VelocityDecodeHandler.java +++ b/velocity/src/main/java/us/myles/ViaVersion/velocity/handlers/VelocityDecodeHandler.java @@ -34,14 +34,14 @@ public class VelocityDecodeHandler extends MessageToMessageDecoder { ByteBuf transformedBuf = ctx.alloc().buffer().writeBytes(bytebuf); try { - boolean needsCompress = handleCompressionOrder(ctx, draft); + boolean needsCompress = handleCompressionOrder(ctx, bytebuf); - info.transformIncoming(draft, CancelDecoderException::generate); + info.transformIncoming(bytebuf, CancelDecoderException::generate); if (needsCompress) { - recompress(ctx, draft); + recompress(ctx, bytebuf); } - out.add(draft.retain()); + out.add(bytebuf.retain()); } finally { transformedBuf.release(); } diff --git a/velocity/src/main/java/us/myles/ViaVersion/velocity/handlers/VelocityEncodeHandler.java b/velocity/src/main/java/us/myles/ViaVersion/velocity/handlers/VelocityEncodeHandler.java index 19f69bec4..be32e1b11 100644 --- a/velocity/src/main/java/us/myles/ViaVersion/velocity/handlers/VelocityEncodeHandler.java +++ b/velocity/src/main/java/us/myles/ViaVersion/velocity/handlers/VelocityEncodeHandler.java @@ -46,7 +46,7 @@ public class VelocityEncodeHandler extends MessageToMessageEncoder { } } - private boolean handleCompressionOrder(ChannelHandlerContext ctx, ByteBuf draft) throws InvocationTargetException { + private boolean handleCompressionOrder(ChannelHandlerContext ctx, ByteBuf buf) throws InvocationTargetException { //if (handledCompression) return false; int encoderIndex = ctx.pipeline().names().indexOf("compression-encoder"); diff --git a/velocity/src/main/java/us/myles/ViaVersion/velocity/platform/VelocityConnectionManager.java b/velocity/src/main/java/us/myles/ViaVersion/velocity/platform/VelocityConnectionManager.java index 0a14d8df3..c8735ce09 100644 --- a/velocity/src/main/java/us/myles/ViaVersion/velocity/platform/VelocityConnectionManager.java +++ b/velocity/src/main/java/us/myles/ViaVersion/velocity/platform/VelocityConnectionManager.java @@ -1,33 +1,11 @@ package us.myles.ViaVersion.velocity.platform; -import io.netty.channel.ServerChannel; import us.myles.ViaVersion.api.data.UserConnection; import us.myles.ViaVersion.api.platform.ViaConnectionManager; -import java.util.Objects; - public class VelocityConnectionManager extends ViaConnectionManager { @Override - public void onLoginSuccess(UserConnection connection) { - if (connection.isClientSide()) { - System.out.println("backend connect!"); - Objects.requireNonNull(connection, "connection is null!"); - connections.add(connection); - } else { - System.out.println("frontend connect!"); - super.onLoginSuccess(connection); - } - } - - @Override - public void onDisconnect(UserConnection connection) { - if (connection.isClientSide()) { - System.out.println("backend disconnect!"); - Objects.requireNonNull(connection, "connection is null!"); - connections.remove(connection); - } else { - System.out.println("frontend disconnect!"); - super.onDisconnect(connection); - } + public boolean isFrontEnd(UserConnection conn) { + return !conn.isClientSide(); } }