setInstaBreak() публичный Метод

public setInstaBreak ( boolean $instaBreak )
$instaBreak boolean
Пример #1
0
 public function onBreak(BlockBreakEvent $ev)
 {
     $p = $ev->getPlayer();
     $block = $ev->getBlock();
     $item = $ev->getItem()->getId();
     $ev->setInstaBreak(true);
     foreach ($this->ores as $ore) {
         if ($block->getId() === $ore && !$ev->isCancelled()) {
             $ev->setDrops(array());
             $p->sendMessage("§l§dAUTO-SMELTED!");
             $p->getInventory()->addItem(Item::get($this->ingot[$ore]));
             $x = $p->getX();
             $y = $p->getY();
             $z = $p->getZ();
             $p->getLevel()->addSound(new FizzSound(new Vector3($x, $y, $z)));
         }
     }
 }
Пример #2
0
 public function onBreak(BlockBreakEvent $ev)
 {
     //echo __METHOD__.",".__LINE__."\n";//##DEBUG
     if ($ev->isCancelled()) {
         return;
     }
     $pl = $ev->getPlayer();
     if (!$this->getState($pl, false)) {
         return;
     }
     if ($ev->getBlock()->getId() == Block::AIR) {
         return;
     }
     if (!$pl->isCreative() || !$this->creative) {
         if ($this->items && !isset($this->items[$ev->getItem()->getId()])) {
             //echo "Not using an PickAxe\n"; //##DEBUG
             return;
         }
     }
     $ev->setInstaBreak(true);
 }
Пример #3
0
 /**
  * Tries to break a block using a item, including Player time checks if available
  *
  * @param Vector3 $vector
  * @param Item    &$item (if null, can break anything)
  * @param Player  $player
  *
  * @return boolean
  */
 public function useBreakOn(Vector3 $vector, Item &$item = null, Player $player = null)
 {
     $target = $this->getBlock($vector);
     //TODO: Adventure mode checks
     if ($item === null) {
         $item = Item::get(Item::AIR, 0, 0);
     }
     if ($player instanceof Player) {
         $ev = new BlockBreakEvent($player, $target, $item, ($player->getGamemode() & 0x1) === 1 ? true : false);
         $lastTime = $player->lastBreak - 0.1;
         //TODO: replace with true lag
         if (($player->getGamemode() & 0x1) > 0) {
             $ev->setInstaBreak(true);
         } elseif ($lastTime + $target->getBreakTime($item) >= microtime(true)) {
             $ev->setCancelled();
         }
         if ($item instanceof Item and !$target->isBreakable($item) and $ev->getInstaBreak() === false) {
             $ev->setCancelled();
         }
         if (!$player->isOp() and ($distance = $this->server->getConfigInt("spawn-protection", 16)) > -1) {
             $t = new Vector2($target->x, $target->z);
             $s = new Vector2($this->getSpawn()->x, $this->getSpawn()->z);
             if ($t->distance($s) <= $distance) {
                 //set it to cancelled so plugins can bypass this
                 $ev->setCancelled();
             }
         }
         $this->server->getPluginManager()->callEvent($ev);
         if ($ev->isCancelled()) {
             return false;
         }
         $player->lastBreak = microtime(true);
     } elseif ($item instanceof Item and !$target->isBreakable($item)) {
         return false;
     }
     $level = $target->getLevel();
     if ($level instanceof Level) {
         $above = $level->getBlock(new Vector3($target->x, $target->y + 1, $target->z));
         if ($above instanceof Block) {
             if ($above->getID() === Item::FIRE) {
                 $level->setBlock($above, new Air(), true);
             }
         }
     }
     $drops = $target->getDrops($item);
     //Fixes tile entities being deleted before getting drops
     $target->onBreak($item);
     $tile = $this->getTile($target);
     if ($tile instanceof Tile) {
         if ($tile instanceof InventoryHolder) {
             if ($tile instanceof Chest) {
                 $tile->unpair();
             }
             foreach ($tile->getInventory()->getContents() as $item) {
                 $this->dropItem($target, $item);
             }
         }
         $tile->close();
     }
     if ($item instanceof Item) {
         $item->useOn($target);
         if ($item->isTool() and $item->getDamage() >= $item->getMaxDurability()) {
             $item = Item::get(Item::AIR, 0, 0);
         }
     }
     if (!$player instanceof Player or ($player->getGamemode() & 0x1) === 0) {
         foreach ($drops as $drop) {
             if ($drop[2] > 0) {
                 $this->dropItem($vector->add(0.5, 0.5, 0.5), Item::get($drop[0], $drop[1], $drop[2]));
             }
         }
     }
     return true;
 }
Пример #4
0
 /**
  * OnBlockBreak
  *
  * @param BlockBreakEvent $event        	
  */
 public function onBlockBreak(BlockBreakEvent $event)
 {
     if (!$event->getPlayer()->isOp()) {
         $allow = $this->checkBlockBreakAndPlacementPermission($event->getPlayer(), $event->getBlock());
         $this->plugin->log("PlayerLobbyListener->onBlockBreak allow: " . $allow);
         if (!$allow) {
             $event->setCancelled(true);
             //$this->plugin->log("[HG] PlayerLobbyListener: onBlockBreak Cancelled for player " . $event->getPlayer ()->getName () );
         }
         if ($allow) {
             if ($event->getBlock()->getId() === Item::CHEST && !$event->getPlayer()->isOp()) {
                 $message = TextFormat::RED . "You are not allow break Chest";
                 $event->getPlayer()->sendPopup($message);
                 $event->setCancelled(true);
             } else {
                 $this->plugin->log("[HG] PlayerLobbyListener: onBlockBreak ALLOW | " . $event->getPlayer()->getGamemode() . "|" . $event->getPlayer()->getName() . "|" . $event->getPlayer()->getLevel()->getName());
                 $event->setInstaBreak(true);
                 $event->setCancelled(false);
             }
         }
     }
 }
Пример #5
0
 public function onBreak(BlockBreakEvent $event)
 {
     if ($this->active == false and isset($this->players[$event->getPlayer()->getName()])) {
         $event->setCancelled();
     }
     if (isset($this->players[$event->getPlayer()->getName()])) {
         if ($event->getBlock()->getID() != $this->plugin->getConfig()->get("surface")) {
             $event->setCancelled();
         } else {
             if ($this->active == true) {
                 $block = $event->getBlock();
                 $event->setInstaBreak(true);
                 $block = new Position($block->getX(), $block->getY(), $block->getZ(), $block->getLevel());
                 $this->broken[] = $block;
             }
         }
     }
 }
Пример #6
0
 public function onBreak(BlockBreakEvent $ev)
 {
     echo __METHOD__ . "," . __LINE__ . "\n";
     //##DEBUG
     if ($ev->isCancelled()) {
         return;
     }
     $pl = $ev->getPlayer();
     echo __METHOD__ . "," . __LINE__ . "\n";
     //##DEBUG
     if (($m = $this->getState($pl, false)) === false) {
         return;
     }
     echo __METHOD__ . "," . __LINE__ . ":: m={$m}\n";
     //##DEBUG
     if ($m === "insta-break") {
         $ev->setInstaBreak(true);
         return;
     }
     echo __METHOD__ . "," . __LINE__ . "\n";
     //##DEBUG
     if ($ev->getBlock()->getId() == Block::AIR) {
         return;
     }
     if (!$pl->isCreative() || !$this->creative) {
         if ($this->items && !isset($this->items[$ev->getItem()->getId()])) {
             //echo "Not using an PickAxe\n"; //##DEBUG
             return;
         }
     }
     if (substr($ev->getBlock()->getName(), -4) !== " Ore") {
         return;
     }
     // This is an ore...
     $ev->setInstaBreak(true);
     $pl->sendMessage(mc::_("Using VeinMinger"));
     $this->setState($pl, "insta-break");
     //prevents infinite loops...
     $c = $this->veinsearch($ev->getBlock(), $this->blocklimit, $pl, $this->sides);
     $this->setState($pl, true);
     if ($c && $this->broadcast) {
         $this->owner->getServer()->broadcastMessage(mc::n(mc::_("%1% used VeinMiner (one block affected)", $pl->getDisplayName()), mc::_("%1% used VeinMiner (%2% blocks affected)", $pl->getDisplayName(), $c), $c));
     }
 }
Пример #7
0
 public function onBreak(BlockBreakEvent $ev)
 {
     $ev->setInstaBreak(true);
 }