mirror of
https://github.com/ViaVersion/ViaFabric.git
synced 2025-03-09 12:59:09 +01:00
use out bytebuf as draft in encodehandler
This commit is contained in:
parent
8abe965958
commit
322fee616b
@ -42,16 +42,8 @@ public class VREncodeHandler extends MessageToByteEncoder {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void encode(ChannelHandlerContext ctx, Object msg, ByteBuf out) throws Exception {
|
protected void encode(ChannelHandlerContext ctx, Object msg, ByteBuf out) throws Exception {
|
||||||
// Based on Sponge ViaVersion decoder code
|
out.writeBytes((ByteBuf) msg);
|
||||||
if (!(msg instanceof ByteBuf)) throw new EncoderException("Received msg isn't ByteBuf");
|
CommonTransformer.transformServerbound(out, user);
|
||||||
|
|
||||||
ByteBuf draft = ctx.alloc().buffer().writeBytes((ByteBuf) msg);
|
|
||||||
try {
|
|
||||||
CommonTransformer.transformServerbound(draft, user);
|
|
||||||
out.writeBytes(draft);
|
|
||||||
} finally {
|
|
||||||
draft.release();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -42,15 +42,8 @@ public class FabricEncodeHandler extends MessageToByteEncoder {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void encode(final ChannelHandlerContext ctx, Object in, final ByteBuf out) throws Exception {
|
protected void encode(final ChannelHandlerContext ctx, Object in, final ByteBuf out) throws Exception {
|
||||||
if (!(in instanceof ByteBuf)) throw new EncoderException("Received object isn't ByteBuf");
|
out.writeBytes((ByteBuf) in);
|
||||||
|
CommonTransformer.transformClientbound(out, user);
|
||||||
ByteBuf draft = ctx.alloc().buffer().writeBytes((ByteBuf) in);
|
|
||||||
try {
|
|
||||||
CommonTransformer.transformClientbound(draft, user);
|
|
||||||
out.writeBytes(draft);
|
|
||||||
} finally {
|
|
||||||
draft.release();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -58,4 +51,4 @@ public class FabricEncodeHandler extends MessageToByteEncoder {
|
|||||||
if (PipelineUtil.containsCause(cause, CancelException.class)) return;
|
if (PipelineUtil.containsCause(cause, CancelException.class)) return;
|
||||||
super.exceptionCaught(ctx, cause);
|
super.exceptionCaught(ctx, cause);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user