Skip to content

Commit

Permalink
showfake: remove empty lists
Browse files Browse the repository at this point in the history
  • Loading branch information
mcmonkey4eva committed Jan 28, 2021
1 parent 1b52720 commit 779ee76
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
Expand Up @@ -42,6 +42,9 @@ public void remove(FakeBlock block) {
List<FakeBlock> chunkBlocks = byChunk.get(block.chunkCoord);
if (chunkBlocks != null) {
chunkBlocks.remove(block);
if (chunkBlocks.isEmpty()) {
byChunk.remove(block.chunkCoord);
}
}
}
}
Expand Down Expand Up @@ -124,6 +127,9 @@ public void cancelBlock() {
}
FakeBlockMap mapping = blocks.get(player.getUUID());
mapping.remove(this);
if (mapping.byChunk.isEmpty()) {
blocks.remove(player.getUUID());
}
}

private void updateBlock(MaterialTag material, DurationTag duration) {
Expand Down
Expand Up @@ -616,7 +616,7 @@ public boolean processShowFakeForPacket(Packet<?> packet, GenericFutureListener<
int chunkZ = CHUNKZ_MAPCHUNK.getInt(packet);
ChunkCoordinate chunkCoord = new ChunkCoordinate(chunkX, chunkZ, player.getWorld().getWorld().getName());
List<FakeBlock> blocks = FakeBlock.getFakeBlocksFor(player.getUniqueID(), chunkCoord);
if (blocks == null) {
if (blocks == null || blocks.isEmpty()) {
return false;
}
PacketPlayOutMapChunk newPacket = FakeBlockHelper.handleMapChunkPacket((PacketPlayOutMapChunk) packet, blocks);
Expand Down

0 comments on commit 779ee76

Please sign in to comment.