From 274b80a6829b15bb95d6a95b61c17ed70eb35764 Mon Sep 17 00:00:00 2001 From: creeper123123321 Date: Fri, 17 Aug 2018 19:04:21 -0300 Subject: [PATCH] Fix sendRawPacket, do not use bungee movement transmitter --- .../viarift/handler/VRInHandler.java | 4 ++-- .../viarift/platform/VRLoader.java | 5 +---- .../viarift/platform/VRUserConnection.java | 2 +- .../viarift/util/PipelineUtil.java | 16 ++++++++++++++++ 4 files changed, 20 insertions(+), 7 deletions(-) create mode 100644 src/main/java/com/github/creeper123123321/viarift/util/PipelineUtil.java diff --git a/src/main/java/com/github/creeper123123321/viarift/handler/VRInHandler.java b/src/main/java/com/github/creeper123123321/viarift/handler/VRInHandler.java index f0c0f0e..3bcfb54 100644 --- a/src/main/java/com/github/creeper123123321/viarift/handler/VRInHandler.java +++ b/src/main/java/com/github/creeper123123321/viarift/handler/VRInHandler.java @@ -34,10 +34,10 @@ public class VRInHandler extends ByteToMessageDecoder { if (user.isActive()) { // Handle ID int id = Type.VAR_INT.read(msg); - // Transform - ByteBuf newPacket = msg.alloc().buffer(); if (id != PacketWrapper.PASSTHROUGH_ID) { + // Transform + ByteBuf newPacket = msg.alloc().buffer(); try { PacketWrapper wrapper = new PacketWrapper(id, msg, user); ProtocolInfo protInfo = user.get(ProtocolInfo.class); diff --git a/src/main/java/com/github/creeper123123321/viarift/platform/VRLoader.java b/src/main/java/com/github/creeper123123321/viarift/platform/VRLoader.java index 968f72c..4214dc1 100644 --- a/src/main/java/com/github/creeper123123321/viarift/platform/VRLoader.java +++ b/src/main/java/com/github/creeper123123321/viarift/platform/VRLoader.java @@ -1,14 +1,11 @@ package com.github.creeper123123321.viarift.platform; -import us.myles.ViaVersion.api.Via; import us.myles.ViaVersion.api.platform.ViaPlatformLoader; -import us.myles.ViaVersion.bungee.providers.BungeeMovementTransmitter; -import us.myles.ViaVersion.protocols.protocol1_9to1_8.providers.MovementTransmitterProvider; public class VRLoader implements ViaPlatformLoader { @Override public void load() { - Via.getManager().getProviders().use(MovementTransmitterProvider.class, new BungeeMovementTransmitter()); + } @Override diff --git a/src/main/java/com/github/creeper123123321/viarift/platform/VRUserConnection.java b/src/main/java/com/github/creeper123123321/viarift/platform/VRUserConnection.java index 5210783..2f6ac10 100644 --- a/src/main/java/com/github/creeper123123321/viarift/platform/VRUserConnection.java +++ b/src/main/java/com/github/creeper123123321/viarift/platform/VRUserConnection.java @@ -1,5 +1,6 @@ package com.github.creeper123123321.viarift.platform; +import com.github.creeper123123321.viarift.util.PipelineUtil; import io.netty.buffer.ByteBuf; import io.netty.channel.Channel; import io.netty.channel.ChannelFuture; @@ -7,7 +8,6 @@ import io.netty.channel.socket.SocketChannel; import us.myles.ViaVersion.api.PacketWrapper; import us.myles.ViaVersion.api.data.UserConnection; import us.myles.ViaVersion.api.type.Type; -import us.myles.ViaVersion.util.PipelineUtil; public class VRUserConnection extends UserConnection { diff --git a/src/main/java/com/github/creeper123123321/viarift/util/PipelineUtil.java b/src/main/java/com/github/creeper123123321/viarift/util/PipelineUtil.java new file mode 100644 index 0000000..2dca112 --- /dev/null +++ b/src/main/java/com/github/creeper123123321/viarift/util/PipelineUtil.java @@ -0,0 +1,16 @@ +package com.github.creeper123123321.viarift.util; + +import io.netty.channel.ChannelHandlerContext; +import io.netty.channel.ChannelPipeline; + +public class PipelineUtil { + public static ChannelHandlerContext getContextBefore(String name, ChannelPipeline pipe) { + String previous = null; + for (String current : pipe.names()) { + if (name.equals(current)) + break; + previous = current; + } + return pipe.context(previous); + } +}