Skip to content

Commit

Permalink
Do not throw exception here if maxLength is 0
Browse files Browse the repository at this point in the history
  • Loading branch information
Alemiz112 committed May 20, 2024
1 parent c73682a commit aeeadd2
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ public void readEntityData(ByteBuf buffer, EntityDataMap entityDataMap) {
checkNotNull(entityDataMap, "entityDataDictionary");

int length = VarInts.readUnsignedInt(buffer);
checkArgument(length <= this.encodingSettings.maxListSize(), "Entity data size is too big: {}", length);
checkArgument(this.encodingSettings.maxListSize() == 0 || length <= this.encodingSettings.maxListSize(), "Entity data size is too big: %s", length);

for (int i = 0; i < length; i++) {
int id = VarInts.readUnsignedInt(buffer);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public void readEntityData(ByteBuf buffer, EntityDataMap entityDataMap) {
checkNotNull(entityDataMap, "entityDataDictionary");

int length = VarInts.readUnsignedInt(buffer);
checkArgument(length <= this.encodingSettings.maxListSize(), "Entity data size is too big: {}", length);
checkArgument(this.encodingSettings.maxListSize() == 0 || length <= this.encodingSettings.maxListSize(), "Entity data size is too big: %s", length);

for (int i = 0; i < length; i++) {
int id = VarInts.readUnsignedInt(buffer);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,10 @@ public void deserialize(ByteBuf buffer, BedrockCodecHelper helper, ClientCacheBl
int maxLength = helper.getEncodingSettings().maxListSize();

int naksLength = VarInts.readUnsignedInt(buffer);
checkArgument(naksLength <= maxLength, "Tried to read %s Nacks but maximum is %s", naksLength, maxLength);
checkArgument(maxLength == 0 || naksLength <= maxLength, "Tried to read %s Nacks but maximum is %s", naksLength, maxLength);

int acksLength = VarInts.readUnsignedInt(buffer);
checkArgument(acksLength <= maxLength, "Tried to read %s Nacks but maximum is %s", acksLength, maxLength);
checkArgument(maxLength == 0 || acksLength <= maxLength, "Tried to read %s Nacks but maximum is %s", acksLength, maxLength);

LongList naks = packet.getNaks();
for (int i = 0; i < naksLength; i++) {
Expand Down

0 comments on commit aeeadd2

Please sign in to comment.