Update ViaVersion, try to fix UserConnection#sendRawPacket

This commit is contained in:
creeper123123321 2018-08-17 18:20:18 -03:00
parent 53be441e01
commit 2f0ea9d55e
3 changed files with 18 additions and 15 deletions

View File

@ -36,7 +36,7 @@ configurations {
}
dependencies {
shade ('us.myles:viaversion:1.4.1') { transitive = false }
shade ('us.myles:viaversion:1.4.2-SNAPSHOT') { transitive = false }
implementation 'org.dimdev:mixin:0.7.11-SNAPSHOT'
compile 'org.dimdev.rift:Rift:1.0.1:dev'
}

View File

@ -37,17 +37,19 @@ public class VRInHandler extends ByteToMessageDecoder {
// Transform
ByteBuf newPacket = msg.alloc().buffer();
try {
PacketWrapper wrapper = new PacketWrapper(id, msg, user);
ProtocolInfo protInfo = user.get(ProtocolInfo.class);
protInfo.getPipeline().transform(Direction.OUTGOING, protInfo.getState(), wrapper);
wrapper.writeToBuffer(newPacket);
msg = newPacket;
} catch (Exception e) {
if (!(e instanceof CancelException))
e.printStackTrace();
msg.clear();
throw e;
if (id != PacketWrapper.PASSTHROUGH_ID) {
try {
PacketWrapper wrapper = new PacketWrapper(id, msg, user);
ProtocolInfo protInfo = user.get(ProtocolInfo.class);
protInfo.getPipeline().transform(Direction.OUTGOING, protInfo.getState(), wrapper);
wrapper.writeToBuffer(newPacket);
msg = newPacket;
} catch (Exception e) {
if (!(e instanceof CancelException))
e.printStackTrace();
msg.clear();
throw e;
}
}
}

View File

@ -7,6 +7,7 @@ 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 {
@ -28,14 +29,14 @@ public class VRUserConnection extends UserConnection {
final Channel channel = this.getChannel();
if (currentThread) {
try {
channel.pipeline().context("decoder").fireChannelRead(copy);
PipelineUtil.getContextBefore("decoder", channel.pipeline()).fireChannelRead(copy);
} catch (Exception e) {
e.printStackTrace();
}
} else {
channel.eventLoop().submit(() -> {
try {
channel.pipeline().context("decoder").fireChannelRead(copy);
PipelineUtil.getContextBefore("decoder", channel.pipeline()).fireChannelRead(copy);
} catch (Exception e) {
e.printStackTrace();
}
@ -55,7 +56,7 @@ public class VRUserConnection extends UserConnection {
packet.release();
final Channel channel = this.getChannel();
try {
channel.pipeline().context("decoder").fireChannelRead(copy);
PipelineUtil.getContextBefore("decoder", channel.pipeline()).fireChannelRead(copy);
} catch (Exception e) {
e.printStackTrace();
}