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


PHP InventoryPickupItemEvent::setCancelled方法代碼示例

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


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

示例1: onPickUp

 public function onPickUp(InventoryPickupItemEvent $event)
 {
     if ($event->getPlayer() instanceof Player && $this->plugin->status === "enabled" && $this->plugin->loginmanager[$event->getPlayer()->getId()] !== true && $this->plugin->allowPickup !== true) {
         $event->setCancelled(true);
     } elseif ($this->plugin->safemode === true and $this->plugin->status !== "enabled") {
         $event->setCancelled(true);
         $event->getPlayer()->sendMessage($this->disable);
     }
 }
開發者ID:EpicArtz08999,項目名稱:xAuth,代碼行數:9,代碼來源:LoginTasks.php

示例2: onPickupItem

 public function onPickupItem(InventoryPickupItemEvent $event)
 {
     $player = $event->getInventory()->getHolder();
     if (!$this->isLogin($player)) {
         $event->setCancelled();
         return true;
     }
 }
開發者ID:pid011,項目名稱:SimpleLogin,代碼行數:8,代碼來源:EventListener.php

示例3: onPickup

 public function onPickup(InventoryPickupItemEvent $event)
 {
     $player = $event->getInventory()->getHolder();
     if ($player instanceof Player) {
         if ($event->getItem()->getItem()->getId() === self::GUN_ID) {
             $this->players[$player->getName()][0]->addAmmo(30);
             if ($player->getInventory()->contains(Item::get(self::GUN_ID))) {
                 $event->getItem()->kill();
                 $event->setCancelled();
             }
         } else {
             $event->getItem()->kill();
         }
     }
 }
開發者ID:EmreTr1,項目名稱:MineCombat,代碼行數:15,代碼來源:MineCombat.php

示例4: onPickupItem

 /**
  * @param InventoryPickupItemEvent $event
  *
  * @priority LOWEST
  */
 public function onPickupItem(InventoryPickupItemEvent $event)
 {
     $player = $event->getInventory()->getHolder();
     if ($player instanceof Player and !$this->auth->isPlayerAuthenticated($player)) {
         $event->setCancelled(true);
     }
 }
開發者ID:jigibbs123,項目名稱:pocketmine-plugins,代碼行數:12,代碼來源:EventListener.php

示例5: onPickupItem

 public function onPickupItem(InventoryPickupItemEvent $event)
 {
     $holder = $event->getInventory()->getHolder();
     if (!$holder instanceof Player) {
         return;
     }
     $session = $this->main->getSession($holder);
     if (!$session instanceof Session) {
         $event->setCancelled();
         return;
     }
     if ($session->onPickupItem($event) === false) {
         $event->setCancelled();
     }
 }
開發者ID:legoboy0215,項目名稱:LegionPE-Theta-Base,代碼行數:15,代碼來源:SessionEventListener.php

示例6: h_onPickup

 public function h_onPickup(InventoryPickupItemEvent $event)
 {
     if (!$this->isLoggedIn()) {
         $event->setCancelled();
     }
 }
開發者ID:LegionPE,項目名稱:LegionPE-Eta,代碼行數:6,代碼來源:Session.php

示例7: onPickupItem

 /**
  * @param InventoryPickupItemEvent $event
  *
  * @priority HIGH
  * @ignoreCancelled true
  */
 public function onPickupItem(InventoryPickupItemEvent $event)
 {
     $player = $event->getInventory()->getHolder();
     if ($player instanceof Player and !$player->isOp()) {
         foreach ($this->plugin->getAllZones() as $zone) {
             if ($zone->isIn($event->getItem())) {
                 if ($player->hasPermission($zone->getName() . MEMBER)) {
                     break;
                 }
                 $event->setCancelled(true);
                 $player->sendMessage("[iZone] This is a private area.");
                 break;
             }
         }
     }
 }
開發者ID:Tee7even,項目名稱:iZone,代碼行數:22,代碼來源:EventManager.php

示例8: onPickup

 public function onPickup(InventoryPickupItemEvent $event)
 {
     $player = $event->getInventory()->getHolder();
     if ($player instanceof Player) {
         if ($this->inArena($player)) {
             if (!in_array($event->getItem()->getId(), $this->pickup)) {
                 if ($event->getItem()->getItem()->getId() == Item::BRICK) {
                     $event->setCancelled();
                     $player->getLevel()->removeEntity($event->getItem());
                     $this->pickup[] = $event->getItem()->getId();
                     $player->setExpLevel($player->getExpLevel() + 1);
                     $player->sendTip(TextFormat::GOLD . "+" . TextFormat::GREEN . "1 Level!");
                 }
                 if ($event->getItem()->getItem()->getId() == Item::IRON_INGOT) {
                     $event->setCancelled();
                     $player->getLevel()->removeEntity($event->getItem());
                     $this->pickup[] = $event->getItem()->getId();
                     $player->setExpLevel($player->getExpLevel() + 10);
                     $player->sendTip(TextFormat::GOLD . "+" . TextFormat::GREEN . "10 Level!");
                 }
                 if ($event->getItem()->getItem()->getId() == Item::GOLD_INGOT) {
                     $event->setCancelled();
                     $player->getLevel()->removeEntity($event->getItem());
                     $this->pickup[] = $event->getItem()->getId();
                     $player->setExpLevel($player->getExpLevel() + 20);
                     $player->sendTip(TextFormat::GOLD . "+" . TextFormat::GREEN . "20 Level!");
                 }
             }
         }
     }
 }
開發者ID:Bluplayz,項目名稱:BedwarsPE,代碼行數:31,代碼來源:Bedwars.php

示例9: onPick

 public function onPick(InventoryPickupItemEvent $event)
 {
     $inv = $event->getInventory();
     if (!$inv instanceof PlayerInventory) {
         return;
     }
     $player = $inv->getHolder();
     if (!$player instanceof Player) {
         return;
     }
     $user = $this->main->getUserByPlayer($player);
     if ($user === null or !$user->isPlaying()) {
         $event->setCancelled();
     }
 }
開發者ID:GoneTone,項目名稱:HereAuth,代碼行數:15,代碼來源:EventRouter.php

示例10: onPickup

 public function onPickup(InventoryPickupItemEvent $event)
 {
     $player = $event->getInventory()->getHolder();
     if ($player instanceof Player) {
         $item = $event->getItem()->getItem();
         if (isset($this->loadedGuns[$item->getId() . ":" . $item->getDamage()])) {
             $gun = $this->players[$player->getName()][0];
             if ($gun->getGunItem() === $item->getId() . ":" . $item->getDamage()) {
                 $gun->addAmmo($gun->getMagazineAmmo());
                 $event->getItem()->kill();
             }
             $event->setCancelled();
         } else {
             $event->getItem()->kill();
         }
     }
 }
開發者ID:EmeraldGem585,項目名稱:MineCombat,代碼行數:17,代碼來源:MineCombat.php

示例11: onPickup

 public function onPickup(InventoryPickupItemEvent $event)
 {
     $inv = $event->getInventory();
     if (!$inv instanceof PlayerInventory) {
         return;
     }
     $player = $inv->getHolder();
     if (!$player instanceof Player) {
         return;
     }
     $session = $this->getMain()->getSessions()->getSession($player);
     if (!$session->inSession($this)) {
         return;
     }
     $item = $event->getItem();
     if ($item instanceof ItemBlock) {
         if ($item->getBlock() === Block::SNOW_BLOCK) {
             $event->setCancelled();
         }
     }
 }
開發者ID:LegionPE,項目名稱:LegionPE-Eta,代碼行數:21,代碼來源:SpleefGame.php


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