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


PHP PlayerInteractEvent::isCancelled方法代码示例

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


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

示例1: 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

示例2: crateKeys

 public function crateKeys(PlayerInteractEvent $event)
 {
     $player = $event->getPlayer();
     $block = $event->getBlock();
     if ($block->getId() == $this->getConfig()->get("Crate") && !$event->isCancelled()) {
         if ($player->getInventory()->getItemInHand()->getId() == $this->getConfig()->get("CrateKey-Item")) {
             $prizes = array(Item::get(rand($this->getConfig()->get("ID-1"), $this->getConfig()->get("ID-2")), 0, $this->getConfig()->get("number-of-items")));
             foreach ($prizes as $prize) {
                 $player->getInventory()->addItem($prize);
             }
             $player->sendMessage($this->getConfig()->get("completed"));
             $player->getInventory()->removeItem(item::get($this->getConfig()->get("CrateKey-Item"), 0, 1));
             $event->setCancelled(true);
         } else {
             $player->sendMessage($this->getConfig()->get("failed"));
             $event->setCancelled(true);
         }
     } elseif (!$event->isCancelled()) {
         $event->setCancelled(false);
     }
 }
开发者ID:MCPH,项目名称:CrateKeys,代码行数:21,代码来源:Main.php

示例3: onPlayerInteract

 public function onPlayerInteract(PlayerInteractEvent $event)
 {
     if ($event->isCancelled()) {
         return;
     }
     $player = $event->getPlayer();
     $block = $event->getBlock();
     $key = $player->getName();
     if (isset($this->doubleTouchQueue[$key])) {
         if (abs(time() - $this->doubleTouchQueue[$key]["time"]) < 2000) {
             /** @var $lastBlock Block */
             $lastBlock = $this->doubleTouchQueue[$key]["block"];
             if ($block->getX() === $lastBlock->getX() and $block->getY() === $lastBlock->getY() and $block->getZ() === $lastBlock->getZ()) {
                 if ($this->chopTree($player, $block, $event->getItem(), self::TYPE_DOUBLE_TOUCH)) {
                     $event->setCancelled(true);
                 }
             }
         }
         unset($this->doubleTouchQueue[$key]);
     } else {
         $this->doubleTouchQueue[$key] = ["time" => time(), "block" => $block];
     }
 }
开发者ID:nesgohood,项目名称:PMMP-Plugins,代码行数:23,代码来源:ChopTree.php

示例4: onInteract

 public function onInteract(PlayerInteractEvent $ev)
 {
     if ($ev->isCancelled()) {
         return;
     }
     if (isset($this->watchers[strtolower($ev->getPlayer()->getName())])) {
         $ev->setCancelled();
     }
 }
开发者ID:DWWf,项目名称:pocketmine-plugins,代码行数:9,代码来源:CmdSpectator.php

示例5: onInteract

 public function onInteract(PlayerInteractEvent $ev)
 {
     if ($ev->isCancelled()) {
         return;
     }
     $pl = $ev->getPlayer();
     $world = $pl->getLevel()->getName();
     if (!isset($this->wcfg[$world])) {
         return;
     }
     $item = $ev->getItem();
     if (!isset($this->wcfg[$world][$item->getId()])) {
         return;
     }
     $pl->sendMessage(mc::_("You can not use that item here!"));
     $ev->setCancelled();
 }
开发者ID:HeechFive,项目名称:pocketmine-plugins,代码行数:17,代码来源:BanItem.php

示例6: onTouch

 public function onTouch(PlayerInteractEvent $ev)
 {
     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;
         }
     }
     $bl = $ev->getBlock();
     if ($this->items && $this->itemwear) {
         $hand = $pl->getInventory()->getItemInHand();
         $bl->getLevel()->useBreakOn($bl, $hand, $pl);
         $pl->getInventory()->setItemInHand($hand);
     } else {
         $bl->getLevel()->useBreakOn($bl, null, $pl);
     }
 }
开发者ID:DWWf,项目名称:pocketmine-plugins,代码行数:27,代码来源:PowerTool.php

示例7: onPlayerInteract

 public function onPlayerInteract(PlayerInteractEvent $event)
 {
     if (!$event->isCancelled()) {
         $this->checkArea($event);
     }
 }
开发者ID:Skull3x,项目名称:MineBlock,代码行数:6,代码来源:ProtectArea.php

示例8: onPlayerInteract

 public function onPlayerInteract(PlayerInteractEvent $event)
 {
     if (!$event->isCancelled()) {
         $this->protectBlock($event);
     }
 }
开发者ID:Skull3x,项目名称:MineBlock,代码行数:6,代码来源:ProtectBlock.php

示例9: onPlayerInteract

 /**
  * @priority HIGHEST
  */
 public function onPlayerInteract(PlayerInteractEvent $event)
 {
     if ($event->isCancelled()) {
         return;
     }
     $p = $event->getPlayer();
     $b = $event->getBlock();
     if ($b->getID() !== 92 || $p->getHealth() >= $p->getMaxHealth()) {
         return;
     }
     $this->getServer()->getPluginManager()->callEvent($ev = new EntityRegainHealthEvent($p, 3, EntityRegainHealthEvent::CAUSE_EATING));
     if (!$ev->isCancelled()) {
         if (($dmg = $b->getDamage() + 1) >= 0x6) {
             $b->getLevel()->setBlock($b, Block::get(0, 0));
         } else {
             $b->getLevel()->setBlock($b, Block::get(92, $dmg));
         }
         $p->heal($ev->getAmount(), $ev);
     }
 }
开发者ID:Skull3x,项目名称:MineBlock,代码行数:23,代码来源:MaxHealth.php


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