mirror of
https://github.com/ViaVersion/ViaFabric.git
synced 2025-03-02 03:41:02 +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
|
||||
protected void encode(ChannelHandlerContext ctx, Object msg, ByteBuf out) throws Exception {
|
||||
// Based on Sponge ViaVersion decoder code
|
||||
if (!(msg instanceof ByteBuf)) throw new EncoderException("Received msg isn't ByteBuf");
|
||||
|
||||
ByteBuf draft = ctx.alloc().buffer().writeBytes((ByteBuf) msg);
|
||||
try {
|
||||
CommonTransformer.transformServerbound(draft, user);
|
||||
out.writeBytes(draft);
|
||||
} finally {
|
||||
draft.release();
|
||||
}
|
||||
out.writeBytes((ByteBuf) msg);
|
||||
CommonTransformer.transformServerbound(out, user);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -42,15 +42,8 @@ public class FabricEncodeHandler extends MessageToByteEncoder {
|
||||
|
||||
@Override
|
||||
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");
|
||||
|
||||
ByteBuf draft = ctx.alloc().buffer().writeBytes((ByteBuf) in);
|
||||
try {
|
||||
CommonTransformer.transformClientbound(draft, user);
|
||||
out.writeBytes(draft);
|
||||
} finally {
|
||||
draft.release();
|
||||
}
|
||||
out.writeBytes((ByteBuf) in);
|
||||
CommonTransformer.transformClientbound(out, user);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -58,4 +51,4 @@ public class FabricEncodeHandler extends MessageToByteEncoder {
|
||||
if (PipelineUtil.containsCause(cause, CancelException.class)) return;
|
||||
super.exceptionCaught(ctx, cause);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user