Skip to content

Commit

Permalink
Fixed duplicated door log when breaking.
Browse files Browse the repository at this point in the history
  • Loading branch information
matcracker committed Apr 27, 2020
1 parent a9e09ac commit 13c5434
Showing 1 changed file with 10 additions and 9 deletions.
19 changes: 10 additions & 9 deletions src/matcracker/BedcoreProtect/listeners/BlockListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ public function trackBlockBreak(BlockBreakEvent $event): void
if ($block instanceof Door) {
$top = $block->getDamage() & 0x08;
$other = $block->getSide($top ? Vector3::SIDE_DOWN : Vector3::SIDE_UP);
if ($other instanceof Door and $other->getId() === $block->getId()) {
if ($other instanceof Door) {
$this->blocksQueries->addBlockLogByEntity($player, $other, $air, Action::BREAK(), $other->asPosition());
}
} elseif ($block instanceof Bed) {
Expand All @@ -83,24 +83,25 @@ public function trackBlockBreak(BlockBreakEvent $event): void
$this->inventoriesQueries->addInventoryLogByPlayer($player, $inventory, $block->asPosition());
}
}
}

$this->blocksQueries->addBlockLogByEntity($player, $block, $air, Action::BREAK(), $block->asPosition());

if ($this->plugin->getParsedConfig()->getNaturalBreak()) {
} elseif ($this->plugin->getParsedConfig()->getNaturalBreak()) {
/**
* @var Block[] $sides
* Getting all blocks around the broken block that are consequently destroyed.
*/
$sides = array_filter($block->getAllSides(), static function (Block $side): bool {
return $side->canBePlaced() && !$side->isSolid() && $side->isTransparent();
});
$sides = array_filter(
$block->getAllSides(),
function (Block $side): bool {
return $side->canBePlaced() && !$side->isSolid() && $side->isTransparent();
}
);

if (count($sides) > 0) {
$this->blocksQueries->addBlocksLogByEntity($player, $sides, $air, Action::BREAK());
}
}

$this->blocksQueries->addBlockLogByEntity($player, $block, $air, Action::BREAK(), $block->asPosition());

}
}

Expand Down

0 comments on commit 13c5434

Please sign in to comment.