Mirror von
https://github.com/PaperMC/Velocity.git
synchronisiert 2024-11-17 05:20:14 +01:00
Fix Brigadier command node redirect serialization (#565)
Dieser Commit ist enthalten in:
Ursprung
321f1306f3
Commit
1b069fc611
@ -44,17 +44,24 @@ public class MinecraftVarintFrameDecoder extends ByteToMessageDecoder {
|
|||||||
if (varintEnd == -1) {
|
if (varintEnd == -1) {
|
||||||
// We tried to go beyond the end of the buffer. This is probably a good sign that the
|
// We tried to go beyond the end of the buffer. This is probably a good sign that the
|
||||||
// buffer was too short to hold a proper varint.
|
// buffer was too short to hold a proper varint.
|
||||||
|
if (reader.getResult() == DecodeResult.RUN_OF_ZEROES) {
|
||||||
|
// Special case where the entire packet is just a run of zeroes. We ignore them all.
|
||||||
|
in.clear();
|
||||||
|
}
|
||||||
return;
|
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 readVarint = reader.getReadVarint();
|
||||||
int bytesRead = reader.getBytesRead();
|
int bytesRead = reader.getBytesRead();
|
||||||
if (readVarint < 0) {
|
if (readVarint < 0) {
|
||||||
in.clear();
|
in.clear();
|
||||||
throw BAD_LENGTH_CACHED;
|
throw BAD_LENGTH_CACHED;
|
||||||
} else if (readVarint == 0) {
|
} else if (readVarint == 0) {
|
||||||
// skip over the empty packet and ignore it
|
// skip over the empty packet(s) and ignore it
|
||||||
in.readerIndex(varintEnd + 1);
|
in.readerIndex(varintEnd + 1);
|
||||||
} else {
|
} else {
|
||||||
int minimumRead = bytesRead + readVarint;
|
int minimumRead = bytesRead + readVarint;
|
||||||
|
@ -27,6 +27,14 @@ class VarintByteDecoder implements ByteProcessor {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean process(byte k) {
|
public boolean process(byte k) {
|
||||||
|
if (k == 0 && bytesRead == 0) {
|
||||||
|
// tentatively say it's invalid, but there's a possibility of redemption
|
||||||
|
result = DecodeResult.RUN_OF_ZEROES;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
if (result == DecodeResult.RUN_OF_ZEROES) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
readVarint |= (k & 0x7F) << bytesRead++ * 7;
|
readVarint |= (k & 0x7F) << bytesRead++ * 7;
|
||||||
if (bytesRead > 3) {
|
if (bytesRead > 3) {
|
||||||
result = DecodeResult.TOO_BIG;
|
result = DecodeResult.TOO_BIG;
|
||||||
@ -54,6 +62,7 @@ class VarintByteDecoder implements ByteProcessor {
|
|||||||
public enum DecodeResult {
|
public enum DecodeResult {
|
||||||
SUCCESS,
|
SUCCESS,
|
||||||
TOO_SHORT,
|
TOO_SHORT,
|
||||||
TOO_BIG
|
TOO_BIG,
|
||||||
|
RUN_OF_ZEROES
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -122,6 +122,9 @@ public class AvailableCommands implements MinecraftPacket {
|
|||||||
if (!idMappings.containsKey(child)) {
|
if (!idMappings.containsKey(child)) {
|
||||||
idMappings.put(child, idMappings.size());
|
idMappings.put(child, idMappings.size());
|
||||||
childrenQueue.addAll(child.getChildren());
|
childrenQueue.addAll(child.getChildren());
|
||||||
|
if (child.getRedirect() != null) {
|
||||||
|
childrenQueue.add(child.getRedirect());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren