Mirror von
https://github.com/PaperMC/Velocity.git
synchronisiert 2024-11-17 05:20:14 +01:00
Avoid ByteBuf#slice(). We can simply reset the reader index.
Dieser Commit ist enthalten in:
Ursprung
1a2b162353
Commit
564b87de1d
@ -17,7 +17,7 @@ public class MinecraftVarintFrameDecoder extends ByteToMessageDecoder {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
ByteBuf lenBuf = ctx.alloc().buffer(3);
|
ByteBuf lenBuf = ctx.alloc().buffer(3).writeZero(3);
|
||||||
int origReaderIndex = in.readerIndex();
|
int origReaderIndex = in.readerIndex();
|
||||||
try {
|
try {
|
||||||
for (int i = 0; i < 3; i++) {
|
for (int i = 0; i < 3; i++) {
|
||||||
@ -27,9 +27,11 @@ public class MinecraftVarintFrameDecoder extends ByteToMessageDecoder {
|
|||||||
}
|
}
|
||||||
|
|
||||||
byte read = in.readByte();
|
byte read = in.readByte();
|
||||||
lenBuf.writeByte(read);
|
lenBuf.setByte(i, read);
|
||||||
if (read > 0) {
|
if (read > 0) {
|
||||||
int packetLength = ProtocolUtils.readVarInt(lenBuf.slice());
|
// Make sure reader index of length buffer is returned to the beginning
|
||||||
|
lenBuf.readerIndex(0);
|
||||||
|
int packetLength = ProtocolUtils.readVarInt(lenBuf);
|
||||||
if (packetLength == 0) {
|
if (packetLength == 0) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren