3
0
Mirror von https://github.com/ViaVersion/ViaVersion.git synchronisiert 2024-12-27 08:30:09 +01:00

Merge branch 'master' into dev

Dieser Commit ist enthalten in:
Myles 2021-02-09 16:32:44 +00:00
Commit d1a0d629df
2 geänderte Dateien mit 36 neuen und 20 gelöschten Zeilen

Datei anzeigen

@ -31,12 +31,15 @@ public class BukkitDecodeHandler extends ByteToMessageDecoder {
throw CancelDecoderException.generate(null); throw CancelDecoderException.generate(null);
} }
ByteBuf transformedBuf = null;
try {
if (info.shouldTransformPacket()) { if (info.shouldTransformPacket()) {
info.transformIncoming(bytebuf, CancelDecoderException::generate); transformedBuf = ctx.alloc().buffer().writeBytes(bytebuf);
info.transformIncoming(transformedBuf, CancelDecoderException::generate);
} }
try { try {
list.addAll(PipelineUtil.callDecode(this.minecraftDecoder, ctx, bytebuf)); list.addAll(PipelineUtil.callDecode(this.minecraftDecoder, ctx, transformedBuf == null ? bytebuf : transformedBuf));
} catch (InvocationTargetException e) { } catch (InvocationTargetException e) {
if (e.getCause() instanceof Exception) { if (e.getCause() instanceof Exception) {
throw (Exception) e.getCause(); throw (Exception) e.getCause();
@ -44,6 +47,11 @@ public class BukkitDecodeHandler extends ByteToMessageDecoder {
throw (Error) e.getCause(); throw (Error) e.getCause();
} }
} }
} finally {
if (transformedBuf != null) {
transformedBuf.release();
}
}
} }
@Override @Override

Datei anzeigen

@ -28,12 +28,15 @@ public class SpongeDecodeHandler extends ByteToMessageDecoder {
throw CancelDecoderException.generate(null); throw CancelDecoderException.generate(null);
} }
ByteBuf transformedBuf = null;
try {
if (info.shouldTransformPacket()) { if (info.shouldTransformPacket()) {
info.transformIncoming(bytebuf, CancelDecoderException::generate); transformedBuf = ctx.alloc().buffer().writeBytes(bytebuf);
info.transformIncoming(transformedBuf, CancelDecoderException::generate);
} }
try { try {
list.addAll(PipelineUtil.callDecode(this.minecraftDecoder, ctx, bytebuf)); list.addAll(PipelineUtil.callDecode(this.minecraftDecoder, ctx, transformedBuf == null ? bytebuf : transformedBuf));
} catch (InvocationTargetException e) { } catch (InvocationTargetException e) {
if (e.getCause() instanceof Exception) { if (e.getCause() instanceof Exception) {
throw (Exception) e.getCause(); throw (Exception) e.getCause();
@ -41,6 +44,11 @@ public class SpongeDecodeHandler extends ByteToMessageDecoder {
throw (Error) e.getCause(); throw (Error) e.getCause();
} }
} }
} finally {
if (transformedBuf != null) {
transformedBuf.release();
}
}
} }
@Override @Override