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


PHP PlayerInteractEvent::setCancelled方法代码示例

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


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

示例1: onPlayerInteract

 /**
  * @param PlayerInteractEvent $event
  *
  * @priority HIGHEST
  */
 public function onPlayerInteract(PlayerInteractEvent $event)
 {
     echo __METHOD__ . "," . __LINE__ . "\n";
     //##DEBUG
     if (!$this->auth->isPlayerAuthenticated($event->getPlayer())) {
         echo __METHOD__ . "," . __LINE__ . "\n";
         //##DEBUG
         $event->setCancelled(true);
     }
 }
开发者ID:jigibbs123,项目名称:pocketmine-plugins,代码行数:15,代码来源:EventListener.php

示例2: onBlockTouch

 public function onBlockTouch(PlayerInteractEvent $event)
 {
     $player = $event->getPlayer();
     if (!$player->haspermission("worldprotetor.block.break")) {
         $event->setCancelled(true);
     } else {
         $event->setCancelled(false);
     }
 }
开发者ID:HeroGamingZ,项目名称:PocketMine-MP-Plugins,代码行数:9,代码来源:Main.php

示例3: compassTracker

 public function compassTracker(PlayerInteractEvent $ev)
 {
     $p = $ev->getPlayer();
     if ($p->getInventory()->getItemInHand()->getId() === 345 && $ev->getAction() === PlayerInteractEvent::RIGHT_CLICK_AIR) {
         if (in_array($ev->getPlayer()->getName(), $this->compass)) {
             $p->sendMessage("§c§lYou cant use this for 3 minutes!");
             $ev->setCancelled(true);
             return;
         }
         if (!in_array($ev->getPlayer()->getName(), $this->compass)) {
             array_push($this->compass, $ev->getPlayer()->getName());
             $p->sendTip("§c§lYou cant use this for 3 minutes!");
             $task = new Task($this, $ev->getPlayer());
             $this->getServer()->getScheduler()->scheduleDelayedTask($task, 3600);
             $pickqv = [];
             $distSqMap = [];
             foreach ($p->getLevel()->getPlayers() as $player) {
                 asort($distSqMap);
             }
             foreach ($distSqMap as $id => $distSq) {
                 $p->sendMessage("§b§l" . $picked[$id]->getDisplayName() . " §fis §c" . round(sqrt($distSq)) . " §fblocks from you.");
             }
         }
     }
 }
开发者ID:EXkurumi,项目名称:CompassTracker,代码行数:25,代码来源:Main.php

示例4: onInteract

 public function onInteract(PlayerInteractEvent $event)
 {
     if ($this->plugin->status === "enabled" && $this->plugin->loginmanager[$event->getPlayer()->getId()] === 0) {
         $event->setCancelled(true);
     } elseif ($this->plugin->safemode === true and $this->plugin->status !== "enabled") {
         $event->setCancelled(true);
     }
 }
开发者ID:Jackboy320,项目名称:xAuth,代码行数:8,代码来源:LoginTasks.php

示例5: onInteract

 public function onInteract(PlayerInteractEvent $event)
 {
     if ($event->getPlayer()->hasPermission("worldprotector.block.interact")) {
         $event->setCancelled(false);
     } else {
         $event->setCancelled(true);
     }
 }
开发者ID:Pocket-GAD,项目名称:PocketMine-MP-Plugins,代码行数:8,代码来源:EventListener.php

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

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

示例8: onPlayerInteract

 public function onPlayerInteract(PlayerInteractEvent $event)
 {
     $p = $event->getPlayer();
     $i = $event->getItem();
     if ($i->getID() !== 339 || ($money = $i->getDamage()) < 1) {
         return;
     }
     $m = "[Check] ";
     $ik = $this->isKorean();
     if (!isset($this->touch[$n = $p->getName()])) {
         $this->touch[$n] = 0;
     }
     $c = microtime(true) - $this->touch[$n];
     if ($c > 0) {
         $m .= $ik ? "수표를 사용하시려면 다시한번눌러주세요. \n 수표 정보 : " . $money . "\$" : "If you want to use this check, One more touch block \n Check Info : " . $money . "\$";
     } else {
         $i->setCount($i->getCount() - 1);
         $p->getInventory()->setItem($p->getInventory()->getHeldItemSlot(), $i);
         $this->giveMoney($p, $money);
         $m .= $ik ? "수표를 사용하셨습니다.\n 수표 정보 : " . $money . "\$" : "You use the check. \n Check Info : " . $money . "\$";
     }
     $this->touch[$n] = microtime(true) + 1;
     if (isset($m)) {
         $p->sendMessage($m);
     }
     $event->setCancelled();
 }
开发者ID:Skull3x,项目名称:MineBlock,代码行数:27,代码来源:Check.php

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

示例10: onBlockTap

 /**
  * @param PlayerInteractEvent $event
  *
  * @priority HIGH
  */
 public function onBlockTap(PlayerInteractEvent $event)
 {
     // PowerTool
     if ($this->getAPI()->executePowerTool($event->getPlayer(), $event->getItem())) {
         $event->setCancelled(true);
     }
 }
开发者ID:TBNRFrags2468,项目名称:EssentialsPE,代码行数:12,代码来源:OtherEvents.php

示例11: onInteract

 public function onInteract(PlayerInteractEvent $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

示例12: 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}"]);
         $event->setCancelled();
     }
 }
开发者ID:nesgohood,项目名称:PMMP-Plugins,代码行数:8,代码来源:SignCommand.php

示例13: onPlayerInteract

 /**
  * When the player move while
  * he is not logged in, cancel
  * the event
  * @param PlayerInteractEvent $event
  */
 public function onPlayerInteract(PlayerInteractEvent $event)
 {
     $player = $event->getPlayer();
     if (!User::exist($player->getName()) || User::exist($player->getName()) && !User::get($player->getName())->isLogged()) {
         $event->setCancelled(true);
         $player->sendMessage($this->needLogin);
     }
 }
开发者ID:Vavaballz,项目名称:BallzAuth,代码行数:14,代码来源:LoginProtection.php

示例14: onTouchCrate

 public function onTouchCrate(PlayerInteractEvent $e)
 {
     if ($e->getBlock()->getId() == 54) {
         if ($e->getItem()->getId() == $this->getConfig()->get("cratekey-item")) {
             if ($e->getPlayer()->hasPermission("mysterycrates.crates.open")) {
                 $e->setCancelled();
                 $this->openCrate($e->getPlayer());
             }
         }
     }
 }
开发者ID:ChiefArtz,项目名称:MysteryCrates,代码行数:11,代码来源:Main.php

示例15: onInteract

 public function onInteract(PlayerInteractEvent $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");
             }
         }
     }
 }
开发者ID:robske110,项目名称:CustomAreas,代码行数:11,代码来源:EventListener.php


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