Skip to content

Commit 588770b

Browse files
committed
A try to fix overlay and fix playerQuitEvent.
1 parent 19a28b5 commit 588770b

2 files changed

Lines changed: 17 additions & 3 deletions

File tree

src/Sandertv/BlockSniper/listeners/EventListener.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,8 @@ public function onItemSwitch(PlayerItemHeldEvent $event) {
8080
}
8181

8282
public function onPlayerQuit(PlayerQuitEvent $event) {
83-
$this->onItemSwitch();
83+
if($this->getOwner()->hasBrushWandEnabled($event->getPlayer())) {
84+
$this->getOwner()->disableBrushWand($event->getPlayer());
85+
}
8486
}
8587
}

src/Sandertv/BlockSniper/shapes/OverlayShape.php

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,11 +53,23 @@ public function fillShape(): bool {;
5353
$block->getSide(Block::SIDE_WEST),
5454
$block->getSide(Block::SIDE_EAST)
5555
];
56+
$valid = true;
57+
foreach($this->blocks as $possibleBlock) {
58+
if(is_numeric($possibleBlock)) {
59+
if($block->getId() === $possibleBlock) {
60+
$valid = false;
61+
}
62+
} else {
63+
if($block->getId() === Item::fromString($possibleBlock)->getId()) {
64+
$valid = false;
65+
}
66+
}
67+
}
5668
foreach($directions as $direction) {
57-
if($this->level->getBlock($direction)->getId() === Item::AIR) {
69+
if($this->level->getBlock($direction)->getId() === Item::AIR && $valid) {
5870
$randomName = $this->blocks[array_rand($this->blocks)];
5971
$randomBlock = is_numeric($randomName) ? Item::get($randomName)->getBlock() : Item::fromString($randomName)->getBlock();
60-
if($randomBlock !== 0 || strtolower($randomName) === "air" && $block->getId() !== $randomBlock->getId()) {
72+
if(($randomBlock !== 0 || strtolower($randomName) === "air") && $block->getId() !== $randomBlock->getId()) {
6173
$this->level->setBlock($direction, $randomBlock, false, false);
6274
}
6375
}

0 commit comments

Comments
 (0)