From 5303239f6659c066c32fb11d4710b68dcdf26333 Mon Sep 17 00:00:00 2001 From: Andrew Steinborn Date: Sat, 21 Aug 2021 02:23:29 -0400 Subject: [PATCH] fix bug --- .../proxy/protocol/netty/MinecraftVarintFrameDecoder.java | 5 ++++- .../proxy/protocol/netty/VarintByteDecoder.java | 1 - 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/proxy/src/main/java/com/velocitypowered/proxy/protocol/netty/MinecraftVarintFrameDecoder.java b/proxy/src/main/java/com/velocitypowered/proxy/protocol/netty/MinecraftVarintFrameDecoder.java index c1596e4e2..675ddf7f7 100644 --- a/proxy/src/main/java/com/velocitypowered/proxy/protocol/netty/MinecraftVarintFrameDecoder.java +++ b/proxy/src/main/java/com/velocitypowered/proxy/protocol/netty/MinecraftVarintFrameDecoder.java @@ -51,7 +51,10 @@ public class MinecraftVarintFrameDecoder extends ByteToMessageDecoder { return; } - if (reader.getResult() == DecodeResult.SUCCESS) { + if (reader.getResult() == DecodeResult.RUN_OF_ZEROES) { + // this will return to the point where the next varint starts + in.readerIndex(varintEnd); + } else if (reader.getResult() == DecodeResult.SUCCESS) { int readVarint = reader.getReadVarint(); int bytesRead = reader.getBytesRead(); if (readVarint < 0) { diff --git a/proxy/src/main/java/com/velocitypowered/proxy/protocol/netty/VarintByteDecoder.java b/proxy/src/main/java/com/velocitypowered/proxy/protocol/netty/VarintByteDecoder.java index c6fb89b5d..a67371bea 100644 --- a/proxy/src/main/java/com/velocitypowered/proxy/protocol/netty/VarintByteDecoder.java +++ b/proxy/src/main/java/com/velocitypowered/proxy/protocol/netty/VarintByteDecoder.java @@ -33,7 +33,6 @@ class VarintByteDecoder implements ByteProcessor { return true; } if (result == DecodeResult.RUN_OF_ZEROES) { - result = DecodeResult.SUCCESS; return false; } readVarint |= (k & 0x7F) << bytesRead++ * 7;