3
0
Mirror von https://github.com/ViaVersion/ViaVersion.git synchronisiert 2024-11-20 06:50:08 +01:00

Merge branch 'reduce-decode-rewriting'

Dieser Commit ist enthalten in:
Myles 2021-02-09 10:36:13 +00:00
Commit 24b4cd8dbd
2 geänderte Dateien mit 20 neuen und 36 gelöschten Zeilen

Datei anzeigen

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

Datei anzeigen

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