Skip to content

Commit

Permalink
Fix TNT breaking map
Browse files Browse the repository at this point in the history
  • Loading branch information
boi1216 committed Mar 4, 2020
1 parent 8d3acec commit 2bfd099
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions src/BedWars/game/GameListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,9 @@
use pocketmine\event\player\PlayerMoveEvent;
use pocketmine\event\player\PlayerQuitEvent;
use pocketmine\event\server\DataPacketReceiveEvent;
use pocketmine\event\entity\EntityExplodeEvent;
use pocketmine\item\Item;
use pocketmine\entity\object\PrimedTNT;
use pocketmine\network\mcpe\protocol\ModalFormResponsePacket;
use pocketmine\Player;
use pocketmine\utils\TextFormat;
Expand Down Expand Up @@ -77,6 +79,28 @@ public function onSignChange(SignChangeEvent $event) : void{
}
}

public function onExplode(EntityExplodeEvent $ev) : void{
$entity = $ev->getEntity();
if(!$entity instanceof PrimedTNT)return;
$level = $entity->level;
$game = null;
foreach ($level->getPlayers() as $player) {
if($g = $this->plugin->getPlayerGame($player) !== null){
$game = $g;
}
}
if($game == null)return;

$newList = array();

foreach($ev->getBlockList() as $block){
if(in_array(Utils::vectorToString(":", $block->asVector3()), $game->placedBlocks)){
$newList[] = $block;
}
}
$ev->setBlockList($newList);
}

/**
* @param PlayerInteractEvent $event
*/
Expand Down Expand Up @@ -285,6 +309,10 @@ public function onPlace(BlockPlaceEvent $event) : void{
$playerGame->placedBlocks[] = Utils::vectorToString(":", $event->getBlock());
}
}

if($event->getBlock()->getId() == Block::TNT){
$event->getBlock()->ignite();
}
}
}
}
Expand Down

0 comments on commit 2bfd099

Please sign in to comment.