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 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. 4
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));
 }
 /**
  * @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. 6
0
 /**
  * @param EntityExplodeEvent $event
  *
  * @priority        HIGH
  * @ignoreCancelled true
  */
 public function onEntityExplode(EntityExplodeEvent $event)
 {
     if ($this->plugin->getConfig()->get("protect-from-explosion", true) != true) {
         return;
     }
     $radius = $this->plugin->getConfig()->get("explosion-radius", 8);
     foreach ($this->plugin->getAllZones() as $zone) {
         if ($zone->isOnRadius($event->getPosition(), $radius)) {
             $owner = $this->plugin->getServer()->getPlayer($zone->getOwner());
             if ($owner instanceof Player) {
                 $owner->sendMessage('[iZone] Something explode near zone: ' . $zone->getName());
             }
             $event->setCancelled(true);
             break;
         }
     }
     return;
 }
Esempio n. 7
0
 public function onExplode(EntityExplodeEvent $event)
 {
     $event->setCancelled(true);
 }