mirror of
https://github.com/ViaVersion/ViaLegacy.git
synced 2024-11-16 10:55:23 +01:00
Ensure input buffer isn't modified by VV
This commit is contained in:
parent
4959d65984
commit
fb905a1514
@ -19,6 +19,7 @@ package net.raphimc.vialegacy.api.util;
|
||||
|
||||
import com.viaversion.viaversion.api.protocol.packet.PacketType;
|
||||
import com.viaversion.viaversion.api.protocol.packet.PacketWrapper;
|
||||
import com.viaversion.viaversion.protocol.packet.PacketWrapperImpl;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import io.netty.buffer.Unpooled;
|
||||
|
||||
@ -29,7 +30,13 @@ public class PacketUtil {
|
||||
wrapper.setPacketType(null);
|
||||
|
||||
final ByteBuf lengthBuffer = Unpooled.buffer();
|
||||
if (wrapper instanceof PacketWrapperImpl impl && impl.getInputBuffer() != null) {
|
||||
impl.getInputBuffer().markReaderIndex();
|
||||
}
|
||||
wrapper.writeToBuffer(lengthBuffer);
|
||||
if (wrapper instanceof PacketWrapperImpl impl && impl.getInputBuffer() != null) {
|
||||
impl.getInputBuffer().resetReaderIndex();
|
||||
}
|
||||
final int length = lengthBuffer.readableBytes();
|
||||
lengthBuffer.release();
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user