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); */ }
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(); }
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); }
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); } }
/** * @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; }
public function onExplode(EntityExplodeEvent $event) { $event->setCancelled(true); }