当前位置: 首页>>代码示例>>PHP>>正文


PHP PlayerInteractEvent::getBlock方法代码示例

本文整理汇总了PHP中pocketmine\event\player\PlayerInteractEvent::getBlock方法的典型用法代码示例。如果您正苦于以下问题:PHP PlayerInteractEvent::getBlock方法的具体用法?PHP PlayerInteractEvent::getBlock怎么用?PHP PlayerInteractEvent::getBlock使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在pocketmine\event\player\PlayerInteractEvent的用法示例。


在下文中一共展示了PlayerInteractEvent::getBlock方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: onPlayerInteract

 public function onPlayerInteract(PlayerInteractEvent $event)
 {
     if ($event->getPlayer() instanceof Player) {
         $player = $event->getPlayer();
         $block = $event->getBlock();
         if ($this->plugin->blockhud) {
             $event->getPlayer()->sendMessage("TOUCHED " . $block->getId() . " [x=" . round($block->x) . " y=" . round($block->y) . " z=" . round($block->z) . "]");
         }
     }
 }
开发者ID:robozeri,项目名称:SG,代码行数:10,代码来源:PlayerWelcomeListener.php

示例2: onTouch

 public function onTouch(PlayerInteractEvent $event)
 {
     $player = $event->getPlayer();
     $block = $event->getBlock();
     if ($this->plugin->war->getSoldier($player) != null) {
         if ($block->getId() == 54) {
             $event->setCancelled();
             $block = $event->getBlock();
             if (!isset($this->touchinfo[$player->getName()])) {
                 $this->giveRandomItem($player);
                 $this->touchinfo[$player->getName()] = [];
                 array_push($this->touchinfo[$player->getName()], "{$block->getX()}.{$block->getY()}.{$block->getZ()}");
                 $this->plugin->message($player, $this->plugin->get("get-item-from-chest"));
             } else {
                 foreach ($this->touchinfo[$player->getName()] as $stringpos) {
                     if ($stringpos == "{$block->getX()}.{$block->getY()}.{$block->getZ()}") {
                         $this->plugin->alert($player, $this->plugin->get("already-get-item"));
                         return true;
                     }
                 }
                 $this->giveRandomItem($player);
                 array_push($this->touchinfo[$player->getName()], "{$block->getX()}.{$block->getY()}.{$block->getZ()}");
                 $this->plugin->message($player, $this->plugin->get("get-item-from-chest"));
             }
         }
     }
 }
开发者ID:organization,项目名称:MCFTWARS,代码行数:27,代码来源:EventListener.php

示例3: onPlayerTouch

 public function onPlayerTouch(PlayerInteractEvent $event)
 {
     if ($event->getBlock()->getId() == 68 || $event->getBlock()->getId() == 63) {
         $sign = $event->getPlayer()->getLevel()->getTile($event->getBlock());
         if ($sign instanceof Sign) {
             $signtext = $sign->getText();
             if ($signtext[0] == "§l§4[Brawl]") {
                 $player = $event->getPlayer();
                 $name = $player->getName();
                 $this->getServer()->getScheduler()->scheduleRepeatingTask(new Task1($this), 20 * 60);
                 if (empty($signtext[3]) !== true) {
                     $worlds = $signtext[3];
                     $this->getServer()->loadLevel($worlds);
                     $event->getPlayer()->teleport(Server::getInstance()->getLevelByName($worlds)->getSafeSpawn());
                     if ($world = $this->getServer()->getLevelByName($worlds)) {
                         $count = count($world->getPlayers());
                         $player->sendTip(TextFormat::GREEN . "§l§4[Brawl] Téléportation en cour !");
                         $this->getServer()->broadcastMessage("§l§4[Brawl]§a {$name} rejoin la partie §7[{$count}/8]");
                         $player->setNameTag("§7" . $player->getName());
                         $player->setDisplayName("§7" . $player->getName());
                         $duration = $this->cfg->get("Duration");
                         $player->getInventory()->clearAll();
                         if ($this->gameStarted === true & ($this->timer = 60 & count($this->players) > 8 & $player->isOp())) {
                             $event->setCancelled(true);
                             $player->sendMessage("§l§4[Brawl] Tu ne peut pas rejoindre cette partie");
                             $this->refreshSign();
                             return;
                             //sign event use
                         }
                     }
                 }
             }
         }
     }
 }
开发者ID:SuperAdam47,项目名称:BrawlPVP,代码行数:35,代码来源:Main.php

示例4: playerInteract

 public function playerInteract(PlayerInteractEvent $event)
 {
     if ($event->getBlock()->getId() == 35 && $event->getBlock()->getDamage() == 1) {
         $block->level->setBlock($block, Block::get(0));
         $player = $event->getPlayer();
         $player->getInventory()->addItem(new Item(ITEM::COOKIE, 0, 1));
         $player->sendPopup(TextFormat::GRAY . "RandomGive:\n" . TextFormat::YELLOW . "> " . TextFormat::GREEN . "You've received a cookie!");
     }
 }
开发者ID:Assistance-Team,项目名称:RandomGive,代码行数:9,代码来源:Main.php

示例5: onChestOpen

 public function onChestOpen(PlayerInteractEvent $event)
 {
     if ($event->getBlock()->getID() == Main::ITEM_ID) {
         $chest = $event->getPlayer()->getLevel()->getTile($event->getBlock());
         if ($chest instanceof Chest) {
             //Check Command status
             //0
             if ($this->plugin->getCommandStatus($event->getPlayer()->getName()) == 0) {
                 //Check bypass permission
                 if ($event->getPlayer()->hasPermission("chestlocker.bypass") == false) {
                     //Check if Chest is registered
                     if ($this->plugin->isChestRegistered($chest->getLevel()->getName(), $chest->getX(), $chest->getY(), $chest->getZ())) {
                         if ($this->plugin->getChestOwner($chest->getLevel()->getName(), $chest->getX(), $chest->getY(), $chest->getZ()) != strtolower($event->getPlayer()->getName())) {
                             $event->setCancelled(true);
                             $event->getPlayer()->sendMessage($this->plugin->translateColors("&", Main::PREFIX . "&4You aren't the owner of this " . Main::ITEM_NAME_2 . "."));
                         }
                     }
                 }
             }
             //1
             if ($this->plugin->getCommandStatus($event->getPlayer()->getName()) == 1) {
                 //Check if Chest is registered
                 if ($this->plugin->isChestRegistered($chest->getLevel()->getName(), $chest->getX(), $chest->getY(), $chest->getZ())) {
                     if ($this->plugin->getChestOwner($chest->getLevel()->getName(), $chest->getX(), $chest->getY(), $chest->getZ()) != strtolower($event->getPlayer()->getName())) {
                         $event->getPlayer()->sendMessage($this->plugin->translateColors("&", Main::PREFIX . "&4You aren't the owner of this " . Main::ITEM_NAME_2 . "."));
                     } else {
                         $event->getPlayer()->sendMessage($this->plugin->translateColors("&", Main::PREFIX . "&2" . Main::ITEM_NAME . " already locked"));
                     }
                 } else {
                     $event->getPlayer()->sendMessage($this->plugin->translateColors("&", Main::PREFIX . "&2" . Main::ITEM_NAME . " locked"));
                     $this->plugin->lockChest($chest->getLevel()->getName(), $chest->getX(), $chest->getY(), $chest->getZ(), $event->getPlayer()->getName());
                 }
                 $event->setCancelled(true);
                 $this->plugin->setCommandStatus(0, $event->getPlayer()->getName());
             }
             //2
             if ($this->plugin->getCommandStatus($event->getPlayer()->getName()) == 2) {
                 //Check if Chest is registered
                 if ($this->plugin->isChestRegistered($chest->getLevel()->getName(), $chest->getX(), $chest->getY(), $chest->getZ())) {
                     if ($this->plugin->getChestOwner($chest->getLevel()->getName(), $chest->getX(), $chest->getY(), $chest->getZ()) != strtolower($event->getPlayer()->getName())) {
                         $event->getPlayer()->sendMessage($this->plugin->translateColors("&", Main::PREFIX . "&4You aren't the owner of this " . Main::ITEM_NAME_2 . "."));
                     } else {
                         $event->getPlayer()->sendMessage($this->plugin->translateColors("&", Main::PREFIX . "&2" . Main::ITEM_NAME . " unlocked"));
                         $this->plugin->unlockChest($chest->getLevel()->getName(), $chest->getX(), $chest->getY(), $chest->getZ(), $event->getPlayer()->getName());
                     }
                 } else {
                     $event->getPlayer()->sendMessage($this->plugin->translateColors("&", Main::PREFIX . "&2" . Main::ITEM_NAME . " not registered"));
                 }
                 $event->setCancelled(true);
                 $this->plugin->setCommandStatus(0, $event->getPlayer()->getName());
             }
         }
     }
 }
开发者ID:JGTheminer,项目名称:ChestLocker,代码行数:54,代码来源:EventListener.php

示例6: Touch1b

 public function Touch1b(PlayerInteractEvent $cto)
 {
     $blockDis = $cto->getBlock()->getID();
     $block = $cto->getBlock();
     if ($cto->getPlayer()->isOp()) {
         if ($blockDis == $this->ymlBlock) {
             // fix :>
             $cto->getPlayer()->getLevel()->dropItem(new \pocketmine\math\Vector3($block->x, $block->y, $block->z), Item::get($this->ymal["ItemID"]));
         }
     }
 }
开发者ID:NawafCraft,项目名称:DispenserPE,代码行数:11,代码来源:Main.php

示例7: handlePlayerInteractWithChest

 public function handlePlayerInteractWithChest(PlayerInteractEvent $event)
 {
     $player = $event->getPlayer();
     if ($event->getBlock()->getId() == Item::CHEST) {
         if ($player->getInventory()->getItemInHand()->getId() == Item::STICK) {
             $player->sendMessage("[CSCase] Opening Case...");
             $this->inventory->refillRandomItems($player->level, $event->getBlock());
             $player->getInventory()->removeItem(Item::get(280, 0, 1));
         } else {
             $player->sendMessage("[CSCase] You dont have key for opening,\n[CSCase] If you have key in inventory, please, choose in hand !");
             $event->setCancelled(true);
         }
     }
 }
开发者ID:Ragnok123,项目名称:CSCase,代码行数:14,代码来源:CSCase.php

示例8: onTouch

 public function onTouch(PlayerInteractEvent $event)
 {
     $block = $event->getBlock();
     if (isset($this->configData["{$block->x}:{$block->y}:{$block->z}"])) {
         $this->getServer()->getCommandMap()->dispatch($event->getPlayer(), $this->configData["{$block->x}:{$block->y}:{$block->z}"]);
     }
 }
开发者ID:EmreTr1,项目名称:rtr,代码行数:7,代码来源:SignCommand.php

示例9: onInteract

 /**
  * @param PlayerInteractEvent $event
  *
  * @priority LOW
  */
 public function onInteract(PlayerInteractEvent $event)
 {
     if ($event->getAction() !== PlayerInteractEvent::RIGHT_CLICK_BLOCK) {
         return;
     }
     $player = $event->getPlayer();
     $gamer = $this->hub->getGamerForPlayer($player);
     $item = $event->getItem();
     $block = $event->getBlock();
     if ($block instanceof SignPost) {
         $sign = $block->getLevel()->getTile($block);
         if (!$sign instanceof Sign) {
             unset($sign);
         }
     }
     foreach ($this->hub->getJoinMethods() as $method) {
         if (!$method->isLevelCorrect($player->getLevel())) {
             continue;
         }
         if ($method instanceof KeyJoinMethod) {
             if ($method->key === null or $method->key->equals($item, true, false)) {
                 if ($method->lock === null or $method->lock->equals($block)) {
                     $gamer->setModule($this->hub->getModule($method->target));
                     return;
                 }
             }
         } elseif (isset($sign) and $method instanceof SignJoinMethod) {
             if ($method->matches($sign)) {
                 $gamer->setModule($this->hub->getModule($method->target));
                 return;
             }
         }
     }
 }
开发者ID:gitter-badger,项目名称:DynamicHub,代码行数:39,代码来源:JoinListener.php

示例10: onTouch

 public function onTouch(PlayerInteractEvent $event)
 {
     $block = $event->getBlock();
     $player = $event->getPlayer();
     $arena = "0";
     $level = $player->getLevel();
     if ($block->getID() === Block::SNOW_BLOCK) {
         $player->getLevel()->setBlock($block, new Block(Block::AIR));
     }
     if ($block->getId() === Block::SPONGE) {
         $player->sendMessage("Reseting Spleef");
         $X = $this->setup->get("X");
         $X1 = $this->setup->get("X");
         $Y = $this->setup->get("Y");
         $Z = $this->setup->get("Z");
         $Z1 = $this->setup->get("Z");
         for ($Z > $Z1 - 13; $Z < $Z1 + 13; $Z++) {
             $level->setBlock(new Vector3($X - 6, $Y, $Z), new Snow());
             $level->setBlock(new Vector3($X - 5, $Y, $Z), new Snow());
             $level->setBlock(new Vector3($X - 4, $Y, $Z), new Snow());
             $level->setBlock(new Vector3($X - 3, $Y, $Z), new Snow());
             $level->setBlock(new Vector3($X - 2, $Y, $Z), new Snow());
             $level->setBlock(new Vector3($X - 1, $Y, $Z), new Snow());
             $level->setBlock(new Vector3($X, $Y, $Z), new Snow());
             $level->setBlock(new Vector3($X + 1, $Y, $Z), new Snow());
             $level->setBlock(new Vector3($X + 2, $Y, $Z), new Snow());
             $level->setBlock(new Vector3($X + 3, $Y, $Z), new Snow());
             $level->setBlock(new Vector3($X + 4, $Y, $Z), new Snow());
             $level->setBlock(new Vector3($X + 5, $Y, $Z), new Snow());
             $level->setBlock(new Vector3($X + 6, $Y, $Z), new Snow());
         }
     }
 }
开发者ID:SuperDude36,项目名称:Pocketmine-MP-Plugins,代码行数:33,代码来源:Main.php

示例11: onPlayerTouch

 public function onPlayerTouch(PlayerInteractEvent $event)
 {
     $player = $event->getPlayer();
     $b = $event->getBlock();
     $name = $event->getPlayer()->getName();
     $name = strtolower($name);
     if ($b->getID() === 63 || $b->getID() === 68) {
         $sign = $player->getLevel()->getTile($b);
         if (!$sign instanceof Sign) {
             return;
         }
         $sign = $sign->getText();
         if (TextFormat::clean($sign[0]) === '[Checkpoint]') {
             $this->data->set($name, array($player->x, $player->y, $player->z, $player->getLevel()->getName()));
             $this->data->save();
             $player->sendMessage($this->getConfig()->get("CheckpointSaved"));
         }
         if (TextFormat::clean($sign[0]) === '[Earn Reward]') {
             $this->data->remove($name, array($player->x, $player->y, $player->z, $player->getLevel()->getName()));
             $this->data->save();
             $player->sendMessage($this->getConfig()->get("EarnReward"));
             if ($this->getConfig()->get("reward-command")) {
                 $player->getServer()->dispatchCommand(new ConsoleCommandSender(), str_ireplace("{PLAYER}", $player->getName(), $this->getConfig()->get("reward-command")));
                 $player->teleport($player->getLevel()->getSafeSpawn());
             }
         }
     }
     if ($b->getID() === $this->getConfig()->get("CheckPointBlock")) {
         $this->data->set($name, array($player->x, $player->y, $player->z, $player->getLevel()->getName()));
         $this->data->save();
         $player->sendMessage($this->getConfig()->get("CheckpointSaved"));
     }
 }
开发者ID:NL-4-DEVS,项目名称:Parkour,代码行数:33,代码来源:Main.php

示例12: onBlockTap

 public function onBlockTap(PlayerInteractEvent $e)
 {
     $id = $e->getPlayer()->getInventory()->getItemInHand()->getID();
     if ($id == 283) {
         $this->Item_GoldenSword->useItem($e->getPlayer(), $e->getBlock());
     }
 }
开发者ID:moinngmg,项目名称:MagicalAPI_Item,代码行数:7,代码来源:Main.php

示例13: onPlayerInteract

 /**
  * @priority HIGHEST
  */
 public function onPlayerInteract(PlayerInteractEvent $event)
 {
     if ($event->isCancelled()) {
         return;
     }
     $p = $event->getPlayer();
     $b = $event->getBlock();
     if ($b->getID() !== 26) {
         return;
     }
     $event->setCancelled();
     $xTabel = [3 => 1, 1 => -1];
     $b = $b->getSide(5, isset($xTabel[$dmg = $b->getDamage()]) ? $xTabel[$dmg] : 0);
     $zTabel = [0 => 1, 2 => -1];
     $b = $b->getSide(3, isset($zTabel[$dmg]) ? $zTabel[$dmg] : 0);
     $this->getServer()->getPluginManager()->callEvent($ev = new PlayerBedEnterEvent($p, $b));
     if ($ev->isCancelled()) {
         return;
     }
     $property = (new \ReflectionClass("\\pocketmine\\Player"))->getProperty("sleeping");
     $property->setAccessible(true);
     foreach ($p->getLevel()->getNearbyEntities($p->getBoundingBox()->grow(2, 1, 2), $p) as $pl) {
         if ($pl instanceof Player && $pl->isSleeping()) {
             if ($b->distance($property->getValue($pl)) <= 0.1) {
                 $p->sendMessage("This bed is occupied");
                 return;
             }
         }
     }
     $property->setValue($p, $b);
     $p->teleport($b->add(0.5, 0.5, 0.5));
     $p->sendMetadata($p->getViewers());
     $p->sendMetadata($p);
 }
开发者ID:Skull3x,项目名称:MineBlock,代码行数:37,代码来源:HealBed.php

示例14: onPlayerInteract

 public function onPlayerInteract(PlayerInteractEvent $event)
 {
     $player = $event->getPlayer();
     $block = $event->getBlock();
     if ($player instanceof Player) {
         if (round($this->plugin->vipSignPos->x) === round($block->x) and round($this->plugin->vipSignPos->y) === round($block->y) and round($this->plugin->vipSignPos->z) === round($block->z)) {
             if ($this->plugin->vipenforceaccess) {
                 $vip = $this->checkInVIP($event->getPlayer());
                 if (!$vip) {
                     $message = TextFormat::YELLOW . "[HG] Require " . TextFormat::RED . "VIP+ " . TextFormat::YELLOW . "membership.";
                     $event->getPlayer()->sendMessage($message);
                     return;
                 }
             }
             MapPortal::teleportingToLobby($player, $this->plugin->vipLevelName, $this->plugin->vipSpawnPos);
             $this->plugin->log("[HG] teleporting to VIP lodge " . $this->plugin->vipSpawnPos->x . " " . $this->plugin->vipSpawnPos->y . " " . $this->plugin->vipSpawnPos->z);
             $player->sendTip(TextFormat::BOLD . TextFormat::WHITE . "Welcome to " . TextFormat::RED . "[V.I.P.+ " . TextFormat::GOLD . "Lodge]");
             return;
         }
         if (round($this->plugin->vipExitSignPos->x) === round($block->x) and round($this->plugin->vipExitSignPos->y) === round($block->y) and round($this->plugin->vipExitSignPos->z) === round($block->z)) {
             MapPortal::teleportingToLobby($player, $this->plugin->hubLevelName, $this->plugin->hubSpawnPos);
             $this->plugin->log("[HG] teleporting to HG lobby " . $this->plugin->hubSpawnPos->x . " " . $this->plugin->hubSpawnPos->y . " " . $this->plugin->hubSpawnPos->z);
             $player->sendTip(TextFormat::BOLD . TextFormat::WHITE . "Welcome to " . TextFormat::RED . "HG " . TextFormat::GOLD . "Lobby");
             return;
         }
     }
 }
开发者ID:robozeri,项目名称:SG,代码行数:27,代码来源:VIPPlayerListener.php

示例15: onInteract

 public function onInteract(PlayerInteractEvent $event)
 {
     $block = $event->getBlock();
     $player = $event->getPlayer();
     if (isset($this->normalSessions[$player->getName()])) {
         if ($this->normalSessions[$player->getName()] === 'action') {
             $player->sendMessage("Please write your command into chat (with a slash!), other players won't be able to see it!");
             $player->sendMessage("Execution Mode Tags: %pow, %op");
             $player->sendMessage("Special Tags: %p, %x, %y, %z, %l, %ip, %n");
             $this->normalSessions[$player->getName()] = $block;
             $this->cmdSessions[$player->getName()] = false;
         } else {
             if (($tempBlock = $this->getBlock($block, null, null, null)) instanceof Block) {
                 $this->deleteBlock($tempBlock);
                 $player->sendMessage("Removed all actions assigned to the block.");
                 unset($this->normalSessions[$player->getName()]);
             } else {
                 $player->sendMessage("Error: Block doesn't exist.");
             }
         }
     }
     if (!isset($this->normalSessions[$player->getName()]) && ($block = $this->getBlock($event->getBlock(), null, null, null)) instanceof Block && $event->getPlayer()->hasPermission("ttdleet.tap")) {
         $block->executeCommands($event->getPlayer());
     }
 }
开发者ID:DWWf,项目名称:TapToDo-LEET.CC,代码行数:25,代码来源:TapToDo.php


注:本文中的pocketmine\event\player\PlayerInteractEvent::getBlock方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。