From 13c5434bc391401a744222d0aaf5c462447fc505 Mon Sep 17 00:00:00 2001 From: matcracker Date: Mon, 27 Apr 2020 19:28:30 +0200 Subject: [PATCH] Fixed duplicated door log when breaking. --- .../listeners/BlockListener.php | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/src/matcracker/BedcoreProtect/listeners/BlockListener.php b/src/matcracker/BedcoreProtect/listeners/BlockListener.php index 02db6b38..4e992637 100644 --- a/src/matcracker/BedcoreProtect/listeners/BlockListener.php +++ b/src/matcracker/BedcoreProtect/listeners/BlockListener.php @@ -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) { @@ -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()); + } }