Mirror von
https://github.com/PaperMC/Velocity.git
synchronisiert 2024-11-16 21:10:30 +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) {
|
||||
// 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.
|
||||
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;
|
||||
}
|
||||
|
||||
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) {
|
||||
in.clear();
|
||||
throw BAD_LENGTH_CACHED;
|
||||
} 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);
|
||||
} else {
|
||||
int minimumRead = bytesRead + readVarint;
|
||||
|
@ -27,6 +27,14 @@ class VarintByteDecoder implements ByteProcessor {
|
||||
|
||||
@Override
|
||||
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;
|
||||
if (bytesRead > 3) {
|
||||
result = DecodeResult.TOO_BIG;
|
||||
@ -54,6 +62,7 @@ class VarintByteDecoder implements ByteProcessor {
|
||||
public enum DecodeResult {
|
||||
SUCCESS,
|
||||
TOO_SHORT,
|
||||
TOO_BIG
|
||||
TOO_BIG,
|
||||
RUN_OF_ZEROES
|
||||
}
|
||||
}
|
||||
|
@ -122,6 +122,9 @@ public class AvailableCommands implements MinecraftPacket {
|
||||
if (!idMappings.containsKey(child)) {
|
||||
idMappings.put(child, idMappings.size());
|
||||
childrenQueue.addAll(child.getChildren());
|
||||
if (child.getRedirect() != null) {
|
||||
childrenQueue.add(child.getRedirect());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren