Esempio n. 1
0
 public function onExplosion(EntityExplodeEvent $event)
 {
     $levelName = $event->getEntity()->getLevel()->getName();
     if ($this->plugin->isLevelLoaded($levelName)) {
         $event->setCancelled(true);
     }
     /* Allow explosions but only break blocks inside the plot the tnt is in.
              * Disabled due to tnt cannons not being stopped
     
             $levelName = $event->getEntity()->getLevel()->getName();
             if (!$this->plugin->isLevelLoaded($levelName)) {
                 return;
             }
             $plot = $this->plugin->getPlotByPosition($event->getPosition());
             if ($plot === null) {
                 $event->setCancelled(true);
                 return;
             }
             $beginPos = $this->plugin->getPlotPosition($plot);
             $endPos = clone $beginPos;
             $plotSize = $this->plugin->getLevelSettings($levelName)->plotSize;
             $endPos->x += $plotSize;
             $endPos->z += $plotSize;
             $blocks = array_filter($event->getBlockList(), function($block) use($beginPos, $endPos) {
                 if ($block->x >= $beginPos->x and $block->z >= $beginPos->z and $block->x < $endPos->x and $block->z < $endPos->z) {
                     return true;
                 }
                 return false;
             });
             $event->setBlockList($blocks);
             */
 }
Esempio n. 2
0
 public function onExplode(EntityExplodeEvent $ev)
 {
     if ($ev->isCancelled()) {
         return;
     }
     $et = $ev->getEntity();
     $sp = $et->getLevel()->getSpawnLocation();
     $dist = $sp->distance($et);
     if ($dist > $this->owner->getServer()->getSpawnRadius()) {
         return;
     }
     $ev->setCancelled();
 }
Esempio n. 3
0
 public function onExplode(EntityExplodeEvent $ev)
 {
     //echo __METHOD__.",".__LINE__."\n";
     if ($ev->isCancelled()) {
         return;
     }
     $et = $ev->getEntity();
     $world = $et->getLevel()->getName();
     if (!isset($this->wcfg[$world])) {
         return;
     }
     if ($this->wcfg[$world] == "spawn") {
         $sp = $et->getLevel()->getSpawnLocation();
         $dist = $sp->distance($et);
         if ($dist > $this->owner->getServer()->getSpawnRadius()) {
             return;
         }
     }
     $ev->setCancelled();
     $this->owner->getLogger()->notice(TextFormat::RED . mc::_("Explosion was stopped in %1%", $world));
 }
Esempio n. 4
0
 public function onExplosion(EntityExplodeEvent $event)
 {
     $levelName = $event->getEntity()->getLevel()->getName();
     if (!$this->plugin->isLevelLoaded($levelName)) {
         return;
     }
     $plot = $this->plugin->getPlotByPosition($event->getPosition());
     if ($plot === null) {
         $event->setCancelled(true);
         return;
     }
     $beginPos = $this->plugin->getPlotPosition($plot);
     $endPos = clone $beginPos;
     $plotSize = $this->plugin->getLevelSettings($levelName)->plotSize;
     $endPos->x += $plotSize;
     $endPos->z += $plotSize;
     $blocks = array_filter($event->getBlockList(), function ($block) use($beginPos, $endPos) {
         if ($block->x >= $beginPos->x and $block->z >= $beginPos->z and $block->x < $endPos->x and $block->z < $endPos->z) {
             return true;
         }
         return false;
     });
     $event->setBlockList($blocks);
 }
Esempio n. 5
0
 /**
  * @param EntityExplodeEvent $event
  */
 public function onTNTExplode(EntityExplodeEvent $event)
 {
     if ($event->getEntity()->namedtag->getName() === "EssNuke") {
         $event->setBlockList([]);
     }
 }
 /**
  * @param EntityExplodeEvent $event
  * @priority HIGHEST
  * @ignoreCancelled true
  */
 public function onEntityExplode(EntityExplodeEvent $event)
 {
     if (!$this->plugin->getStorage()->getShield($event->getEntity()->getLevel())->isAllowed(Shield::EXPLODING)) {
         $event->setCancelled(true);
     }
 }
Esempio n. 7
0
 public function onEntityExplode(EntityExplodeEvent $event)
 {
     $Entity = $event->getEntity();
     $Level = $Entity->getLevel();
     if (!$this->plugin->game || $this->plugin->game->level_name != $Level->getFolderName()) {
         return;
     }
     $Blocks = $event->getBlockList();
     $Blocks2 = [];
     foreach ($Blocks as $Block) {
         foreach ($this->plugin->game->BlocksPlaced as $Block2) {
             if ($Block->getX() == $Block2->getX() && $Block->getY() == $Block2->getY() && $Block->getZ() == $Block2->getZ()) {
                 $Blocks2[] = $Block;
                 continue;
             }
         }
     }
     $event->setBlockList($Blocks2);
 }