本文整理匯總了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();
}
}
}
示例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;
}
}
}
}
示例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();
}
}
}
示例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!");
}
}
}
}
}
示例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();
}
}
}