13
0
geforkt von Mirrors/Velocity

Handle empty packets too

Dieser Commit ist enthalten in:
Andrew Steinborn 2020-05-31 09:54:47 -04:00
Ursprung c856635ac5
Commit f27aa8e3ba

Datei anzeigen

@ -33,14 +33,17 @@ public class MinecraftVarintFrameDecoder extends ByteToMessageDecoder {
if (reader.result == DecodeResult.SUCCESS) { if (reader.result == DecodeResult.SUCCESS) {
if (reader.readVarint < 0) { if (reader.readVarint < 0) {
throw BAD_LENGTH_CACHED; throw BAD_LENGTH_CACHED;
} } else if (reader.readVarint == 0) {
// skip over the empty packet and ignore it
int minimumRead = reader.bytesRead + reader.readVarint; in.readerIndex(varintEnd + 1);
if (in.isReadable(minimumRead)) {
out.add(in.retainedSlice(varintEnd + 1, reader.readVarint));
in.skipBytes(minimumRead);
} else { } else {
return; int minimumRead = reader.bytesRead + reader.readVarint;
if (in.isReadable(minimumRead)) {
out.add(in.retainedSlice(varintEnd + 1, reader.readVarint));
in.skipBytes(minimumRead);
} else {
return;
}
} }
} else if (reader.result == DecodeResult.TOO_BIG) { } else if (reader.result == DecodeResult.TOO_BIG) {
throw VARINT_BIG_CACHED; throw VARINT_BIG_CACHED;