Compare commits

...
2 Commits
4 changed files with 36 additions and 11 deletions

No files matched your search

+1 -1
View File
@@ -1,4 +1,4 @@
# ViaVersion 0.4.1
# ViaVersion 0.4.3
**Allows the connection of 1.8 clients to 1.9**
This plugin modifies netty to allow connection of 1.9 clients to 1.8,
@@ -24,8 +24,8 @@ public class ViaDecodeHandler extends ByteToMessageDecoder {
@Override
protected void decode(ChannelHandlerContext ctx, ByteBuf bytebuf, List<Object> list) throws Exception {
// use transformers
if(bytebuf.readableBytes() > 0) {
if(info.isActive()) {
if (bytebuf.readableBytes() > 0) {
if (info.isActive()) {
int id = PacketUtil.readVarInt(bytebuf);
// Transform
ByteBuf newPacket = ctx.alloc().buffer();
@@ -33,7 +33,8 @@ public class ViaDecodeHandler extends ByteToMessageDecoder {
incomingTransformer.transform(id, bytebuf, newPacket);
bytebuf = newPacket;
} catch (CancelException e) {
return;
bytebuf.readBytes(bytebuf.readableBytes());
throw e;
}
}
// call minecraft decoder
@@ -41,5 +42,17 @@ public class ViaDecodeHandler extends ByteToMessageDecoder {
}
}
@Override
public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) throws Exception {
if (!(cause.getCause().getCause() instanceof CancelException)) {
if (!(cause.getCause() instanceof CancelException)) {
if (!(cause instanceof CancelException)) {
System.out.println("throwing");
if (cause instanceof Exception)
throw (Exception) cause;
}
}
}
}
}
@@ -44,16 +44,16 @@ public class ViaEncodeHandler extends MessageToByteEncoder {
Object packet = constructor.newInstance(chunk, true, 65535);
ctx.pipeline().writeAndFlush(packet);
}
bytebuf.clear();
return;
bytebuf.readBytes(bytebuf.readableBytes());
throw new CancelException();
}
// call minecraft encoder
PacketUtil.callEncode(this.minecraftEncoder, ctx, o, bytebuf);
}
if (bytebuf.readableBytes() == 0) {
return;
throw new CancelException();
}
if(info.isActive()) {
if (info.isActive()) {
int id = PacketUtil.readVarInt(bytebuf);
// Transform
ByteBuf oldPacket = bytebuf.copy();
@@ -61,12 +61,24 @@ public class ViaEncodeHandler extends MessageToByteEncoder {
try {
outgoingTransformer.transform(id, oldPacket, bytebuf);
} catch (CancelException e) {
bytebuf.clear();
return;
bytebuf.readBytes(bytebuf.readableBytes());
throw e;
} finally {
oldPacket.release();
}
}
}
@Override
public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) throws Exception {
if (!(cause.getCause().getCause() instanceof CancelException)) {
if (!(cause.getCause() instanceof CancelException)) {
if (!(cause instanceof CancelException)) {
System.out.println("throwing");
if (cause instanceof Exception)
throw (Exception) cause;
}
}
}
}
}
+1 -1
View File
@@ -1,6 +1,6 @@
name: ViaVersion
main: us.myles.ViaVersion.ViaVersionPlugin
author: _MylesC
version: 0.4.1
version: 0.4.3
load: startup
loadbefore: [ProtocolLib, ProxyPipe]