예제 #1
10
 /**
  * Tries to break a block using a item, including Player time checks if available
  * It'll try to lower the durability if Item is a tool, and set it to Air if broken.
  *
  * @param Vector3 $vector
  * @param Item    &$item (if null, can break anything)
  * @param Player  $player
  * @param bool    $createParticles
  *
  * @return boolean
  */
 public function useBreakOn(Vector3 $vector, Item &$item = null, Player $player = null, $createParticles = false)
 {
     $target = $this->getBlock($vector);
     //TODO: Adventure mode checks
     if ($item === null) {
         $item = Item::get(Item::AIR, 0, 0);
     }
     if ($player !== null) {
         $ev = new BlockBreakEvent($player, $target, $item, $player->isCreative() ? true : false);
         if ($player->isSurvival() and $item instanceof Item and !$target->isBreakable($item)) {
             $ev->setCancelled();
         } elseif (!$player->isOp() and ($distance = $this->server->getSpawnRadius()) > -1) {
             $t = new Vector2($target->x, $target->z);
             $s = new Vector2($this->getSpawnLocation()->x, $this->getSpawnLocation()->z);
             if (count($this->server->getOps()->getAll()) > 0 and $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;
         }
         $breakTime = $target->getBreakTime($item);
         if ($player->isCreative() and $breakTime > 0.15) {
             $breakTime = 0.15;
         }
         if ($player->hasEffect(Effect::SWIFTNESS)) {
             $breakTime *= 1 - 0.2 * ($player->getEffect(Effect::SWIFTNESS)->getAmplifier() + 1);
         }
         if ($player->hasEffect(Effect::MINING_FATIGUE)) {
             $breakTime *= 1 + 0.3 * ($player->getEffect(Effect::MINING_FATIGUE)->getAmplifier() + 1);
         }
         $breakTime -= 0.05;
         //1 tick compensation
         if (!$ev->getInstaBreak() and $player->lastBreak + $breakTime > microtime(true)) {
             return false;
         }
         $player->lastBreak = microtime(true);
         $drops = $ev->getDrops();
     } elseif ($item !== null and !$target->isBreakable($item)) {
         return false;
     } else {
         $drops = $target->getDrops($item);
         //Fixes tile entities being deleted before getting drops
         foreach ($drops as $k => $i) {
             $drops[$k] = Item::get($i[0], $i[1], $i[2]);
         }
     }
     $above = $this->getBlock(new Vector3($target->x, $target->y + 1, $target->z));
     if ($above !== null) {
         if ($above->getId() === Item::FIRE) {
             $this->setBlock($above, new Air(), true);
         }
     }
     $tag = $item->getNamedTagEntry("CanDestroy");
     if ($tag instanceof Enum) {
         $canBreak = false;
         foreach ($tag as $v) {
             if ($v instanceof String) {
                 $entry = Item::fromString($v->getValue());
                 if ($entry->getId() > 0 and $entry->getBlock() !== null and $entry->getBlock()->getId() === $target->getId()) {
                     $canBreak = true;
                     break;
                 }
             }
         }
         if (!$canBreak) {
             return false;
         }
     }
     if ($createParticles) {
         $players = $this->getChunkPlayers($target->x >> 4, $target->z >> 4);
         if ($player !== null) {
             unset($players[$player->getLoaderId()]);
         }
         $this->addParticle(new DestroyBlockParticle($target->add(0.5), $target), $players);
     }
     $target->onBreak($item);
     $tile = $this->getTile($target);
     if ($tile !== null) {
         if ($tile instanceof InventoryHolder) {
             if ($tile instanceof Chest) {
                 $tile->unpair();
             }
             foreach ($tile->getInventory()->getContents() as $chestItem) {
                 $this->dropItem($target, $chestItem);
             }
         }
         $tile->close();
     }
     if ($item !== null) {
         $item->useOn($target);
         if ($item->isTool() and $item->getDamage() >= $item->getMaxDurability()) {
             $item = Item::get(Item::AIR, 0, 0);
         }
     }
     if ($player === null or $player->isSurvival()) {
         foreach ($drops as $drop) {
             if ($drop->getCount() > 0) {
                 $this->dropItem($vector->add(0.5, 0.5, 0.5), $drop);
             }
         }
     }
     return true;
 }
 /**
  * @param BlockBreakEvent $event
  */
 public function onBlockBreak(BlockBreakEvent $event)
 {
     $player = $event->getPlayer();
     $b = $event->getBlock();
     if ($this->getPlugin()->pos_display_flag == 1) {
         $event->getPlayer()->sendMessage("BREAKED: [x=" . $b->x . " y=" . $b->y . " z=" . $b->z . "]");
     }
     // @fix1- team can only break enermy flag and not own
     $redTeamFlagPos = $this->getSetup()->getFlagPos(CTFSetup::CTF_FLAG_RED_TEAM);
     if (round($b->x) == round($redTeamFlagPos->x) && round($b->y) == round($redTeamFlagPos->y) && round($b->z) == round($redTeamFlagPos->y)) {
         if (isset($this->pgin->redTeamPlayers[$player->getName()])) {
             // update again to fix color issue
             $this->getBuilder()->addBlueTeamFlag($player->getLevel(), 171, 14);
             $event->setCancelled(true);
         }
     }
     $blueTeamFlagPos = $this->getSetup()->getFlagPos(CTFSetup::CTF_FLAG_BLUE_TEAM);
     if (round($b->x) == round($blueTeamFlagPos->x) && round($b->y) == round($blueTeamFlagPos->y) && round($b->z) == round($blueTeamFlagPos->z)) {
         if (isset($this->pgin->blueTeamPLayers[$player->getName()])) {
             // update again to fix color issue
             $this->getBuilder()->addBlueTeamFlag($player->getLevel(), 171, 11);
             $event->setCancelled(true);
         }
     }
     // @fix #2 stop player break anything else other than the flags
     if (strtolower($player->level->getName()) == strtolower($this->getSetup()->getCTFWorldName())) {
         if ($this->getSetup()->isCTFWorldBlockBreakDisable() || !$player->isOp()) {
             if ($b->getId() != 171) {
                 $event->setCancelled(true);
             }
         }
     }
 }
예제 #3
0
 public function onBreak(BlockBreakEvent $event)
 {
     if ($event->getBlock()->getId() != Block::CHEST) {
         return;
     }
     $block = $event->getBlock();
     if (!isset($this->configData["{$block->x}:{$block->y}:{$block->z}"])) {
         return;
     }
     if ($this->configData["{$block->x}:{$block->y}:{$block->z}"] == $event->getPlayer()->getName()) {
         unset($this->configData["{$block->x}:{$block->y}:{$block->z}"]);
         $event->getPlayer()->sendMessage(TextFormat::DARK_AQUA . "상자 보호가 해제되었습니다 !");
         $event->setCancelled();
     } else {
         if ($event->getPlayer()->isOp()) {
             return;
         }
         if ($this->simpleArea != null) {
             $area = $this->simpleArea->db[$block->getLevel()->getFolderName()]->getArea($block->x, $block->z);
             if ($area != null) {
                 if (isset($area["resident"][0]) and $area["resident"][0] == $event->getPlayer()->getName()) {
                     return;
                 }
             }
         }
         $event->getPlayer()->sendMessage(TextFormat::RED . "이 상자는 " . $this->configData["{$block->x}:{$block->y}:{$block->z}"] . " 님의 소유입니다, 파괴 불가 !");
         $event->setCancelled();
     }
 }
 public function onBreak(BlockBreakEvent $event)
 {
     if ($event->getPlayer()->hasPermission("worldprotector.block.break")) {
         $event->setCancelled(false);
     } else {
         $event->setCancelled(true);
     }
 }
 /** 
  * @param BlockBreakEvent $event
  * @priority HIGHEST
  * @ignoreCancelled true
  */
 public function onBlockBreak(BlockBreakEvent $event)
 {
     if (!$this->plugin->getStorage()->getShield($event->getPlayer()->getLevel())->isAllowed(Shield::BREAKING)) {
         $event->setCancelled(true);
         $event->getPlayer()->sendTip($this->plugin->getConfig()->get("breakNotAllowed"));
     }
 }
예제 #6
0
파일: TICTOCK.php 프로젝트: EmreTr1/rtr
 public function onBreak(BlockBreakEvent $event)
 {
     $player = $event->getPlayer();
     if ($player->isCreative()) {
         return;
     }
     $time = round(microtime(true) * 1000);
     if ($event->getBlock()->getBreakTime($event->getItem()) <= 0.2) {
         return;
     }
     if ($time - $this->tictock[$player->getName()] <= 200) {
         if (!isset($this->kick[$player->getName()])) {
             $this->kick[$player->getName()] = 1;
         } else {
             $this->kick[$player->getName()]++;
         }
         if ($this->kick > 2) {
             $player->kick("파괴자모드 감지");
             if (isset($this->kick[$player->getName()])) {
                 unset($this->kick[$player->getName()]);
             }
         }
         $event->setCancelled();
     } else {
         if (isset($this->kick[$player->getName()])) {
             unset($this->kick[$player->getName()]);
         }
     }
     $this->tictock[$player->getName()] = $time;
 }
예제 #7
0
 public function blockBreak(BlockBreakEvent $event)
 {
     //1
     $id = $event->getItem()->getId();
     if ($id == $this->id) {
         $player = $event->getPlayer();
         $username = $player->getName();
         if (empty($this->data[$user][1])) {
             $x = $event->getBlock()->x;
             $y = $event->getBlock()->y;
             $z = $event->getBlock()->z;
             $this->data[$user][1] = array($x, $y, $z);
             $ms = "";
             if (isset($this->data[$user][2])) {
                 //片方がセットされていたら
                 $ms = "[FiredNubesco] Second position has been set to: {$x}, {$y}, {$z}";
                 $size = $this->countBlocks($player);
                 if ($num != false) {
                     $ms .= " (Size: " . $size[0] . "X" . $size[1] . ")";
                 }
             } else {
                 $ms = "[FiredNubesco] First position has been set to: {$x}, {$y}, {$z}";
             }
             $player->sendMessage($ms);
             $event->setCancelled(true);
         }
     }
     return true;
 }
 public function onBlockBreakEvent(BlockBreakEvent $event)
 {
     if (!$event->getPlayer()->isOp()) {
         $event->setCancelled(true);
         $this->debug->onDebug('BlockBreakEvent');
     }
 }
예제 #9
0
 public function onBlockBreak(BlockBreakEvent $event)
 {
     $player = $event->getPlayer();
     if (!$player->hasPermission("xperms.build")) {
         $player->sendMessage(TextFormat::RED . $this->plugin->getConfiguration()->getMSGonIBuildPerm());
         $event->setCancelled(true);
     }
 }
 public function onBreak(BlockBreakEvent $event)
 {
     $player = $event->getPlayer();
     if ($event->getBlock()->getId() === FlowerPotMain::BLOCK_ITEM_FRAME and !$player->isOp()) {
         $player->sendMessage("You do not have permission.");
         $event->setCancelled();
     }
 }
예제 #11
0
 public function onBlockBreak(BlockBreakEvent $event)
 {
     if ($this->plugin->isJailed($event->getPlayer())) {
         $event->getPlayer()->sendMessage("§eYou are not allowed to destroy the jail!\nAdded " . $this->getPlugin()->getConfig()->get("punish-additional-minutes") . " minutes as punishment.");
         $this->getPlugin()->punish($event->getPlayer(), $this->getPlugin()->getConfig()->get("punish-additional-minutes"));
         $event->setCancelled(true);
     }
 }
예제 #12
0
 public function onBlockBreak(BlockBreakEvent $event)
 {
     if ($event->isCancelled()) {
         return;
     }
     if ($this->chopTree($event->getPlayer(), $event->getBlock(), $event->getItem(), self::TYPE_BREAK)) {
         $event->setCancelled(true);
     }
 }
 public function playerBlockBreak(BlockBreakEvent $event)
 {
     $block = $event->getBlock();
     if ($block->getID() == Item::WALL_SIGN || $block->getID() == Item::SIGN_POST) {
         $player = $event->getPlayer();
         $signManager = $this->SignShop->getSignManager();
         if ($signManager->existsSign($block)) {
             $get = $signManager->getSign($block);
             if (strtolower($get["maker"]) == strtolower($player->getName())) {
                 if (is_numeric($get["available"]) && $get["need"] > -1) {
                     while ($get["available"] > 0) {
                         $item = new Item($get["id"], $get["damage"], $get["amount"]);
                         if ($player->getInventory()->canAddItem($item)) {
                             if ($get["available"] - $get["amount"] < 0) {
                                 break;
                             }
                             $player->getInventory()->addItem($item);
                             $get["available"] -= $get["amount"];
                         } else {
                             $this->SignShop->messageManager()->send($player, "You_need_to_free_up_space_from_your_inventory_to_remove_this_Sign");
                             $event->setCancelled();
                             return;
                         }
                     }
                 }
                 $signManager->removeSign($block);
                 $this->SignShop->messageManager()->send($player, "The_Sign_successfully_removed");
                 return;
             } else {
                 $this->SignShop->messageManager()->send($player, "The_selected_Sign_is_not_your");
                 $event->setCancelled();
             }
         }
     }
     $pos = $event->getBlock();
     if ($pos->level->getBlockIdAt($pos->x, $pos->y + 1, $pos->z) == Item::SIGN_POST) {
         $pos->level->setBlock($pos, Block::get(0), true, true);
         $pos->y += 1;
         if ($this->SignShop->getSignManager()->existsSign($pos)) {
             $this->SignShop->getSignManager()->spawnSign($pos);
         }
     }
 }
 public function onBlockBeak(BlockBreakEvent $event)
 {
     $log = $event->getPlayer()->getID();
     if (in_array($log, $this->locations)) {
         $ru = $event->getBlock();
         $zoo = strtolower($event->getPlayer()->getName());
         $this->pos[$zoo] = new Vector3($ru->getX(), $ru->getY(), $ru->getZ());
         $event->getPlayer()->sendMessage("BlockPosition :[x->" . $this->pos[$zoo]->getX() . "y->" . $this->pos[$zoo]->getY() . "z->" . $this->pos[$zoo]->getZ() . "]");
         $event->setCancelled(true);
     }
 }
예제 #15
0
 public function onBreak(BlockBreakEvent $event)
 {
     if (!$event->getPlayer()->hasPermission("customareas.bypass")) {
         foreach ($this->plugin->areas as $area) {
             if ($area->isInside($event->getBlock()) and !$area->canBuild($event->getPlayer())) {
                 $event->setCancelled();
                 $event->getPlayer()->sendMessage("This is " . $area->owner . "'s private area");
             }
         }
     }
 }
예제 #16
0
 public function onBlockBreak(BlockBreakEvent $event)
 {
     if ($event->isCancelled()) {
         return;
     } else {
         $event->setCancelled();
     }
     foreach ($event->getBlock()->getDrops($event->getItem()) as $i) {
         $event->getPlayer()->getInventory()->addItem(Item::get(...$i));
     }
 }
 public function onBreak(BlockBreakEvent $event)
 {
     $block = $event->getBlock();
     if ($block instanceof Crops and !$event->getItem()->isHoe()) {
         if ($block->getId() === Block::PUMPKIN_STEM or $block->getId() === Block::MELON_STEM) {
             $event->setCancelled();
         } else {
             $this->blocks[microtime(true) + mt_rand(1, 5) . "." . mt_rand(0, 5)] = $block;
             $this->runTask();
         }
     }
 }
 public function onBlockBreak(BlockBreakEvent $event)
 {
     $block = $event->getBlock();
     $faction = $this->owner->isInPlot($block->getFloorX(), $block->getFloorZ());
     if ($faction) {
         $player = $event->getPlayer();
         if ($faction->getName() !== $this->owner->getPlayerFaction($player) and !$player->hasPermission('uf.break.neutral')) {
             $event->setCancelled(true);
             $player->sendMessage($this->owner->mformatter->formatMessage('This plot has been claimed by: ' . TextFormat::GOLD . $faction . TextFormat::WHITE . ' faction', MessageFormat::INFO));
         }
     }
 }
예제 #19
0
 public function onBlockBreak(BlockBreakEvent $event)
 {
     $player = $event->getPlayer();
     $level = $player->getLevel();
     $spawn = $level->getSpawnLocation();
     $distance = $spawn->distance($player);
     if ($distance <= $this->cfg->get($level->getName())) {
         if (!$player->hasPermission("customradius.edit")) {
             $event->setCancelled(true);
         }
     }
 }
 public function onBlockBreak(BlockBreakEvent $event)
 {
     if ($this->plugin->cfg->get("debugmode") == "true") {
         $this->plugin->getServer()->getLogger()->info(MT::GREEN . "CommandTest BPosition Break");
     }
     $id = $event->getPlayer()->getID();
     if (in_array($id, $this->schalter)) {
         $bl = $event->getBlock();
         $n = strtolower($event->getPlayer()->getName());
         $this->pos[$n] = new Vector3($bl->getX(), $bl->getY(), $bl->getZ());
         $event->getPlayer()->sendMessage(MT::GOLD . "Position(" . $this->pos[$n]->getX() . "," . $this->pos[$n]->getY() . "," . $this->pos[$n]->getZ() . ")");
         $event->setCancelled(true);
     }
 }
예제 #21
0
 public function onSignBreak(BlockBreakEvent $event)
 {
     $player = $event->getPlayer();
     $block = $event->getBlock();
     if ($block instanceof Sign) {
         $sign = $block->getLevel()->getTile($block);
         $text = $sign->getText();
         if (TextFormat::clean(strtolower(trim($text[0]))) === strtolower(trim($this->sign->get("sign_final_change")))) {
             if (!$player->hasPermission("worldstats.break")) {
                 $event->setCancelled(true);
                 $player->sendMessage(TextFormat::RED . "You do not have permission to break a World Status sign.");
             } else {
                 $player->sendMessage(TextFormat::RED . "A World Status sign has been broken!");
             }
         }
     }
 }
예제 #22
0
 /**
  * @param BlockBreakEvent $event
  *
  * @priority        HIGH
  * @ignoreCancelled true
  */
 public function onBlockBreak(BlockBreakEvent $event)
 {
     $player = $event->getPlayer();
     if ($player->isOp()) {
         return;
     }
     foreach ($this->plugin->getAllZones() as $zone) {
         if ($zone->isIn($event->getBlock())) {
             if ($player->hasPermission($zone->getName() . MEMBER)) {
                 break;
             }
             $event->setCancelled(true);
             $player->sendMessage("[iZone] This is a private area.");
             break;
         }
     }
 }
예제 #23
0
 public function onBreak(BlockBreakEvent $event)
 {
     if ($event->getBlock()->getId() === Block::SIGN_POST || $event->getBlock()->getId() === Block::WALL_SIGN) {
         if ($this->tntRun->getSign()->isExists($event->getBlock())) {
             if ($event->getPlayer()->hasPermission("tntrun.create")) {
                 $this->tntRun->getSign()->removeSign($event->getBlock());
             } else {
                 $event->getPlayer()->sendMessage(TextFormat::RED . "You don't have permission to use this command!");
             }
             return;
         }
     }
     foreach ($this->tntRun->arenas as $arena) {
         if ($arena->getPlayerManager()->isInArena($event->getPlayer())) {
             $event->setCancelled();
             return;
         }
     }
 }
예제 #24
0
파일: Main.php 프로젝트: kdani1/iProtector
 public function onBlockBreak(BlockBreakEvent $event)
 {
     $b = $event->getBlock();
     $p = $event->getPlayer();
     $n = strtolower($p->getName());
     if (isset($this->sel1[$n])) {
         unset($this->sel1[$n]);
         $this->pos1[$n] = new Vector3($b->getX(), $b->getY(), $b->getZ());
         $p->sendMessage("Position 1 set to: (" . $this->pos1[$n]->getX() . ", " . $this->pos1[$n]->getY() . ", " . $this->pos1[$n]->getZ() . ")");
         $event->setCancelled();
     } else {
         if (isset($this->sel2[$n])) {
             unset($this->sel2[$n]);
             $this->pos2[$n] = new Vector3($b->getX(), $b->getY(), $b->getZ());
             $p->sendMessage("Position 2 set to: (" . $this->pos2[$n]->getX() . ", " . $this->pos2[$n]->getY() . ", " . $this->pos2[$n]->getZ() . ")");
             $event->setCancelled();
         } else {
             if (!$this->canEdit($p, $b)) {
                 $event->setCancelled();
             }
         }
     }
 }
예제 #25
0
 public function onBlockBreak(BlockBreakEvent $event)
 {
     $block = $event->getBlock();
     $player = $event->getPlayer();
     if (isset($this->touch[$player->getName()])) {
         //$mergeData[$player->getName()][1] = [(int)$block->getX(), (int)$block->getZ()];
         $this->command->mergePosition($player->getName(), 1, [(int) $block->getX(), (int) $block->getZ()]);
         $player->sendMessage("[EconomyProperty] Second position has been saved.");
         $event->setCancelled(true);
         return;
     }
     $info = $this->property->query("SELECT * FROM Property WHERE startX <= {$block->getX()} AND landX >= {$block->getX()} AND startZ <= {$block->getZ()} AND landZ >= {$block->getZ()} AND level = '{$block->getLevel()->getName()}'")->fetchArray(SQLITE3_ASSOC);
     if (is_bool($info) === false) {
         if ($info["x"] === $block->getX() and $info["y"] === $block->getY() and $info["z"] === $block->getZ()) {
             if ($player->hasPermission("economyproperty.property.remove")) {
                 $this->property->exec("DELETE FROM Property WHERE landNum = {$info['landNum']}");
                 $player->sendMessage("[EconomyProperty] You have removed property area #" . $info["landNum"]);
             } else {
                 $event->setCancelled(true);
                 $player->sendMessage("You don't have permission to modify property area.");
             }
         } else {
             if ($player->hasPermission("economyproperty.property.modify") === false) {
                 $event->setCancelled(true);
                 $player->sendMessage("You don't have permission to modify property area.");
             }
         }
     }
 }
 /**
  * @param BlockBreakEvent $event
  */
 public function onPlayerBreakBlock(BlockBreakEvent $event)
 {
     if ($event->getBlock()->getID() == Item::SIGN || $event->getBlock()->getID() == Item::WALL_SIGN || $event->getBlock()->getID() == Item::SIGN_POST) {
         $signt = $event->getBlock();
         if ($tile = $signt->getLevel()->getTile($signt)) {
             if ($tile instanceof Sign) {
                 if ($event->getBlock()->getX() == $this->sign->getNested("sign.x") || $event->getBlock()->getY() == $this->sign->getNested("sign.y") || $event->getBlock()->getZ() == $this->sign->getNested("sign.z")) {
                     if ($event->getPlayer()->hasPermission("signstatus.break")) {
                         $this->sign->setNested("sign.x", $event->getBlock()->getX());
                         $this->sign->setNested("sign.y", $event->getBlock()->getY());
                         $this->sign->setNested("sign.z", $event->getBlock()->getZ());
                         $this->sign->setNested("sign.enabled", false);
                         $this->sign->setNested("sign.level", "world");
                         $this->sign->save();
                         $this->sign->reload();
                         $event->getPlayer()->sendMessage($this->prefix . $this->translation->get("sign_destroyed"));
                     } else {
                         $event->getPlayer()->sendMessage($this->prefix . $this->translation->get("sign_no_perms"));
                         $event->setCancelled();
                     }
                 }
             }
         }
     }
 }
예제 #27
0
 public function onBlockBreak(BlockBreakEvent $ev)
 {
     if ($ev->isCancelled()) {
         return;
     }
     $pl = $ev->getPlayer();
     if ($this->checkBlockPlaceBreak($pl)) {
         return;
     }
     $this->owner->msg($pl, mc::_("You are not allowed to do that here"));
     $ev->setCancelled();
 }
예제 #28
0
 public function onBlockBreak(BlockBreakEvent $event)
 {
     $player = $event->getPlayer();
     if (!$this->isLogin($player)) {
         $event->setCancelled();
         return true;
     }
 }
예제 #29
-1
 public function BlockBreakEven(BlockBreakEvent $event)
 {
     $player = $event->getPlayer();
     if ($player->getInventory()->getItemInHand()->getId() == 286) {
         $event->setCancelled(true);
     }
     if ($player->getInventory()->getItemInHand()->getId() == 285) {
         $event->setCancelled(true);
     }
 }
예제 #30
-1
 /**
  * Tries to break a block using a item, including Player time checks if available
  * It'll try to lower the durability if Item is a tool, and set it to Air if broken.
  *
  * @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);
         if ($player->isSurvival() and $item instanceof Item and !$target->isBreakable($item)) {
             $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->getSpawnLocation()->x, $this->getSpawnLocation()->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;
         }
         $breakTime = $player->isCreative() ? 0.15 : $target->getBreakTime($item);
         if (!$ev->getInstaBreak() and $player->lastBreak + $breakTime >= microtime(true)) {
             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 $chestItem) {
                 $this->dropItem($target, $chestItem);
             }
         }
         $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->isSurvival()) {
         foreach ($drops as $drop) {
             if ($drop[2] > 0) {
                 $this->dropItem($vector->add(0.5, 0.5, 0.5), Item::get(...$drop));
             }
         }
     }
     return true;
 }