當前位置: 首頁>>代碼示例>>PHP>>正文


PHP BlockBreakEvent::getBlock方法代碼示例

本文整理匯總了PHP中pocketmine\event\block\BlockBreakEvent::getBlock方法的典型用法代碼示例。如果您正苦於以下問題:PHP BlockBreakEvent::getBlock方法的具體用法?PHP BlockBreakEvent::getBlock怎麽用?PHP BlockBreakEvent::getBlock使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在pocketmine\event\block\BlockBreakEvent的用法示例。


在下文中一共展示了BlockBreakEvent::getBlock方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: onBreak

 public function onBreak(BlockBreakEvent $e)
 {
     $p = $e->getPlayer();
     $b = $e->getBlock();
     if ($e->getBlock()->getId() == 1 && mt_rand(0, $this->getConfig()->get("t1-chance")) == "1") {
         for ($i = 0; $i <= 5; $i++) {
             $p->getLevel()->addParticle(new LavaParticle($b, 2));
         }
         $p->getLevel()->addSound(new PopSound($p));
         $this->getServer()->broadcastMessage(TextFormat::LIGHT_PURPLE . TextFormat::BOLD . "<TL> " . TextFormat::RESET . TextFormat::GREEN . $p->getName() . TextFormat::AQUA . " found " . TextFormat::BOLD . TextFormat::RED . "Tier 1" . TextFormat::RESET . TextFormat::AQUA . " loot underground!");
         foreach ($this->getConfig()->get("t1-loot") as $loot) {
             $p->getInventory()->addItem(Item::get($loot, 0, mt_rand(0, $this->getConfig()->get("t1-item-max"))));
         }
     }
     if ($e->getBlock()->getId() == 1 && mt_rand(0, $this->getConfig()->get("t2-chance")) == "1") {
         for ($i = 0; $i <= 8; $i++) {
             $p->getLevel()->addParticle(new LavaParticle($b, 2));
         }
         $p->getLevel()->addSound(new PopSound($p));
         $this->getServer()->broadcastMessage(TextFormat::LIGHT_PURPLE . TextFormat::BOLD . "<TL> " . TextFormat::RESET . TextFormat::GREEN . $p->getName() . TextFormat::AQUA . " found " . TextFormat::BOLD . TextFormat::GOLD . "Tier 2" . TextFormat::RESET . TextFormat::AQUA . " loot underground!");
         foreach ($this->getConfig()->get("t2-loot") as $loot) {
             $p->getInventory()->addItem(Item::get($loot, 0, mt_rand(0, $this->getConfig()->get("t2-item-max"))));
         }
     }
     if ($e->getBlock()->getId() == 1 && mt_rand(0, $this->getConfig()->get("t3-chance")) == "1") {
         for ($i = 0; $i <= 11; $i++) {
             $p->getLevel()->addParticle(new LavaParticle($b, 2));
         }
         $p->getLevel()->addSound(new PopSound($p));
         $this->getServer()->broadcastMessage(TextFormat::LIGHT_PURPLE . TextFormat::BOLD . "<TL> " . TextFormat::RESET . TextFormat::GREEN . $p->getName() . TextFormat::AQUA . " found " . TextFormat::BOLD . TextFormat::YELLOW . "Tier 3" . TextFormat::RESET . TextFormat::AQUA . " loot underground!");
         foreach ($this->getConfig()->get("t3-loot") as $loot) {
             $p->getInventory()->addItem(Item::get($loot, 0, mt_rand(0, $this->getConfig()->get("t3-item-max"))));
         }
     }
 }
開發者ID:XFuryMCPE,項目名稱:TierLoot,代碼行數:35,代碼來源:Main.php

示例2: blockBreak

 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;
 }
開發者ID:nao20010128nao,項目名稱:FiredNubesco,代碼行數:29,代碼來源:PluginMain.php

示例3: onBreak

 public function onBreak(BlockBreakEvent $event)
 {
     if ($event->getBlock() instanceof Bed) {
         foreach ($this->getConfig()->get("Arenas") as $arena => $g) {
             $bx = $event->getBlock()->getX();
             $by = $event->getBlock()->getY();
             $bz = $event->getBlock()->getZ();
             $blockpos = new Position($bx, $by, $bz);
             $bl = $event->getBlock()->getLevel()->getName();
             $bpos = $g["bluebed"];
             $rpos = $g["redbed"];
             $gpos = $g["greenbed"];
             $ypos = $g["yellowbed"];
             if ($blockpos === $bpos and $bl === $g["world"]) {
                 foreach ($this->getServer()->getLevelByName($g["world"])->getPlayers() as $p) {
                     $p->sendMessage(TextFormat::DARK_GRAY . "E' stato rotto il letto" . TextFormat::BLUE . "Blu" . TextFormat::DARK_GRAY . "! I giocatori blu sono stati eliminati!");
                 }
             } elseif ($blockpos === $rpos and $bl === $g["world"]) {
                 foreach ($this->getServer()->getLevelByName($g["world"])->getPlayers() as $p) {
                     $p->sendMessage(TextFormat::DARK_GRAY . "E' stato rotto il letto" . TextFormat::RED . "Rosso" . TextFormat::DARK_GRAY . "! I giocatori rossi sono stati eliminati!");
                 }
             } elseif ($blockpos === $gpos and $bl === $g["world"]) {
                 foreach ($this->getServer()->getLevelByName($g["world"])->getPlayers() as $p) {
                     $p->sendMessage(TextFormat::DARK_GRAY . "E' stato rotto il letto" . TextFormat::GREEN . "Verde" . TextFormat::DARK_GRAY . "! I giocatori verdi sono stati eliminati!");
                 }
             } elseif ($blockpos === $ypos and $bl === $g["world"]) {
                 foreach ($this->getServer()->getLevelByName($g["world"])->getPlayers() as $p) {
                     $p->sendMessage(TextFormat::DARK_GRAY . "E' stato rotto il letto" . TextFormat::YELLOW . "Giallo" . TextFormat::DARK_GRAY . "! I giocatori gialli sono stati eliminati!");
                 }
             }
         }
     }
 }
開發者ID:AbelGamerC,項目名稱:BedWars,代碼行數:33,代碼來源:Main.php

示例4: onBreak

 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();
     }
 }
開發者ID:nesgohood,項目名稱:PMMP-Plugins,代碼行數:29,代碼來源:ChestGuard.php

示例5: onBlockBreak

 public function onBlockBreak(BlockBreakEvent $event)
 {
     $key = $event->getBlock()->x . "." . $event->getBlock()->y . "." . $event->getBlock()->z;
     foreach ($this->crops as $crop) {
         if ($event->getItem()->getId() == $crop["item"] and isset($this->farmData[$key])) {
             unset($this->farmData[$key]);
         }
     }
 }
開發者ID:pilock,項目名稱:Farms,代碼行數:9,代碼來源:Farms.php

示例6: onBreak

 public function onBreak(BlockBreakEvent $event)
 {
     if ($event->getBlock()->getId() == 15) {
         $drops = array(Item::get(265, 0, 1));
         $event->setDrops($drops);
     }
     if ($event->getBlock()->getId() == 14) {
         $drops = array(Item::get(266, 0, 1));
         $event->setDrops($drops);
     }
 }
開發者ID:LilianRise,項目名稱:OreInstantDrop,代碼行數:11,代碼來源:Main.php

示例7: SignBreak

 public function SignBreak(BlockBreakEvent $event)
 {
     $block = $event->getBlock();
     if (isset($this->configData["{$block->x}:{$block->y}:{$block->z}"])) {
         unset($this->configData["{$block->x}:{$block->y}:{$block->z}"]);
     }
 }
開發者ID:EmreTr1,項目名稱:rtr,代碼行數:7,代碼來源:SignCommand.php

示例8: onBreak

 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;
 }
開發者ID:EmreTr1,項目名稱:rtr,代碼行數:30,代碼來源:TICTOCK.php

示例9: onBlockBreak

 /**
  * @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);
             }
         }
     }
 }
開發者ID:JiangsNetworkAlpha,項目名稱:CaptureTheFlag,代碼行數:36,代碼來源:CTFListener.php

示例10: onBreak

 public function onBreak(BlockBreakEvent $event)
 {
     if ($event->isCancelled()) {
         return;
     }
     $player = $event->getPlayer();
     $block = $event->getBlock();
     $drops = $block->getDrops($event->getItem());
     $x = $block->x + 0.5;
     $y = $block->y + 0.5;
     $z = $block->z + 0.5;
     $tile = $block->getLevel()->getTile($block);
     if ($tile instanceof Chest) {
         return;
     }
     if ($event->getItem() instanceof Item) {
         $event->getItem()->useOn($block);
         if ($event->getItem()->isTool() and $event->getItem()->getDamage() >= $event->getItem()->getMaxDurability()) {
             $event->getPlayer()->getInventory()->setItemInHand(Item::get(Item::AIR, 0, 0));
         }
     }
     if (!$player instanceof Player) {
         foreach ($drops as $drop) {
             if ($drop[2] > 0) {
                 $event->getBlock()->getLevel()->dropItem($event->getBlock()->add(0.5, 0.5, 0.5), Item::get(...$drop));
             }
         }
     } else {
         if ($player->isSurvival()) {
             $this->breakQueue["{$block->x}:{$block->y}:{$block->z}"]["drop"] = $drops;
             $this->breakQueue["{$block->x}:{$block->y}:{$block->z}"]["player"] = $player;
             $this->itemQueue["{$x}:{$y}:{$z}"] = $drops;
         }
     }
 }
開發者ID:EmreTr1,項目名稱:rtr,代碼行數:35,代碼來源:ItemConsume.php

示例11: onBlockBreak

 /**
  *
  * @param BlockBreakEvent $event        	
  */
 public function onBlockBreak(BlockBreakEvent $event)
 {
     if ($event->getPlayer() instanceof Player) {
         if ($this->plugin->gameLevelManager->setupModeAction === GameLevelManager::COMMAND_SETUP_WAND_GAME_LEVEL || $this->plugin->gameLevelManager->setupModeAction === GameLevelManager::COMMAND_SETUP_WAND_GAME_LEVEL_GATE) {
             $this->plugin->gameLevelManager->handleBlockBreakSelection($event->getPlayer(), $event->getBlock());
         }
     }
 }
開發者ID:robozeri,項目名稱:SG,代碼行數:12,代碼來源:GameLevelListener.php

示例12: onBlockBreak

 public function onBlockBreak(BlockBreakEvent $event)
 {
     if ($event->getBlock()->getID() == 323 || $event->getBlock()->getID() == 63 || $event->getBlock()->getID() == 68) {
         $sign = $event->getPlayer()->getLevel()->getTile($event->getBlock());
         if (!$sign instanceof Sign) {
             return;
         }
         $sign = $sign->getText();
         if ($sign[0] == '§6[§4Bail§6]') {
             if ($event->getPlayer()->hasPermission("jail.sign.destroy") || $event->getPlayer()->hasPermission("jail.sign.destroy.bail")) {
                 $event->getPlayer()->sendMessage($this->getPlugin()->colourMessage("&aYou destroyed a bail sign!"));
             } else {
                 $issuer->sendMessage($this->getPlugin()->colourMessage("&cYou don't have permission for this!"));
             }
         }
     }
 }
開發者ID:HerO-0110,項目名稱:Jail,代碼行數:17,代碼來源:BlockListener.php

示例13: onBreak

 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();
     }
 }
開發者ID:beito123,項目名稱:PocketMine-MP-Plugins,代碼行數:8,代碼來源:ExamplePlugin.php

示例14: onBlockBreak

 /**
  *
  * @param BlockBreakEvent $event        	
  */
 public function onBlockBreak(BlockBreakEvent $event)
 {
     if ($event->getPlayer() instanceof Player) {
         if ($this->plugin->arenaManager->setupModeAction === MapArenaManager::COMMAND_SETUP_WAND_ARENA_MAIN || $this->plugin->arenaManager->setupModeAction === MapArenaManager::COMMAND_SETUP_WAND_ARENA_MAIN_PLAYER_SPAWNS || $this->plugin->arenaManager->setupModeAction === MapArenaManager::COMMAND_SETUP_WAND_ARENA_DEATH_MATCH || $this->plugin->arenaManager->setupModeAction === MapArenaManager::COMMAND_SETUP_WAND_ARENA_DEATH_MATCH_SPAWN) {
             $this->plugin->arenaManager->handleBlockBreakSelection($event->getPlayer(), $event->getBlock());
         }
     }
 }
開發者ID:robozeri,項目名稱:SG,代碼行數:12,代碼來源:MapArenaListener.php

示例15: onBlockBreak

 public function onBlockBreak(BlockBreakEvent $event)
 {
     $player = $event->getPlayer();
     $block = $event->getBlock();
     if ($player->hasPermission('log.breaked.block')) {
         $this->plugin->addBreakedBlock($block, $player);
         // ADD TIME
     }
 }
開發者ID:Artide,項目名稱:SupremePlugins,代碼行數:9,代碼來源:EventListener.php


注:本文中的pocketmine\event\block\BlockBreakEvent::getBlock方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。