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


PHP InventoryPickupItemEvent::getItem方法代碼示例

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


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

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

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

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

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

示例5: 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::getItem方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。