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


PHP player\PlayerItemConsumeEvent类代码示例

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


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

示例1: playerItemConsume

 public function playerItemConsume(PlayerItemConsumeEvent $event)
 {
     $player = $event->getPlayer();
     if ($player->getGamemode() == 0) {
         $item = $event->getItem();
         $item_consumed = $item->getID();
         if ($this->isExistsItem($item_consumed)) {
             $event->setCancelled();
             $count = $item->getCount();
             if ($count == 1) {
                 $item = Item::get(0, 0, 0);
             } else {
                 $item->setCount($count - 1);
             }
             $player->getInventory()->setItemInHand($item);
             if ($item_consumed == 367 || $item_consumed == 365) {
                 if ($this->setPlayerPoisoned($player->getDisplayName(), $this->poison[$item_consumed]) == true) {
                     $this->chat($player, "You have been poisoned by food", 4);
                 }
             }
             $var = $this->items[$item_consumed];
             $this->addFoodLevel($player, $var[0]);
             $this->addFoodSaturationLevel($player, $var[1]);
             $this->test($player->getDisplayName());
         }
     }
 }
开发者ID:TDMGamingMC,项目名称:HungerSimulator,代码行数:27,代码来源:EventPlayer.php

示例2: eat

 public function eat(PlayerItemConsumeEvent $ev)
 {
     $p = $ev->getPlayer();
     if ($ev->getItem()->getId() === 322) {
         $p->addEffect(Effect::getEffect(10)->setAmplifier(4)->setDuration(100)->setVisible(true));
         $p->addEffect(Effect::getEffect(21)->setAmplifier(2)->setDuration(20 * 120)->setVisible(true));
     }
 }
开发者ID:ItzFrozenCreeper,项目名称:Golden-Apple,代码行数:8,代码来源:Main.php

示例3: onDrop

 public function onDrop(PlayerItemConsumeEvent $event)
 {
     if ($event->getItem() instanceof Arrow or $event->getItem() instanceof Snowball) {
         if ($event->getItem()->shootingEntity == null) {
             return;
         }
         if (isset($this->object_hash[spl_object_hash($event->getEntity())])) {
             $event->setCancelled();
         }
     }
 }
开发者ID:EmreTr1,项目名称:rtr,代码行数:11,代码来源:burstMode.php

示例4: onConsume

 public function onConsume(PlayerItemConsumeEvent $ev)
 {
     if ($ev->isCancelled()) {
         return;
     }
     $pl = $ev->getPlayer();
     if ($pl->hasPermission("wp.banitem.exempt")) {
         return;
     }
     $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,代码行数:20,代码来源:BanItem.php

示例5: onDataPacketReceiveEvent

 public function onDataPacketReceiveEvent(DataPacketReceiveEvent $event)
 {
     $packet = $event->getPacket();
     $player = $event->getPlayer();
     if ($packet instanceof EntityEventPacket) {
         if ($player->spawned === \true or $player->blocked === \false or $player->isAlive()) {
             $player->craftingType = 0;
             $player->setDataFlag(Player::DATA_FLAGS, Player::DATA_FLAG_ACTION, \false);
             // TODO: check if this should be true
             switch ($packet->event) {
                 case 9:
                     // Eating
                     $items = [Item::APPLE => 4, Item::MUSHROOM_STEW => 10, Item::BEETROOT_SOUP => 10, Item::BREAD => 5, Item::RAW_PORKCHOP => 3, Item::COOKED_PORKCHOP => 8, Item::RAW_BEEF => 3, Item::STEAK => 8, Item::COOKED_CHICKEN => 6, Item::RAW_CHICKEN => 2, Item::MELON_SLICE => 2, Item::GOLDEN_APPLE => 10, Item::PUMPKIN_PIE => 8, Item::CARROT => 4, Item::POTATO => 1, Item::BAKED_POTATO => 6, Item::COOKIE => 2, Item::COOKED_FISH => [0 => 5, 1 => 6], Item::RAW_FISH => [0 => 2, 1 => 2, 2 => 1, 3 => 1]];
                     $slot = $player->getInventory()->getItemInHand();
                     if (isset($items[$slot->getId()])) {
                         $this->getServer()->getPluginManager()->callEvent($ev = new PlayerItemConsumeEvent($player, $slot));
                         if ($ev->isCancelled()) {
                             $player->getInventory()->sendContents($this);
                             break;
                         }
                         $pk = new EntityEventPacket();
                         $pk->eid = $player->getId();
                         $pk->event = EntityEventPacket::USE_ITEM;
                         $player->dataPacket($pk);
                         Server::broadcastPacket($player->getViewers(), $pk);
                         $amount = $items[$slot->getId()];
                         if (\is_array($amount)) {
                             $amount = isset($amount[$slot->getDamage()]) ? $amount[$slot->getDamage()] : 0;
                         }
                         $ev = new EntityRegainHealthEvent($player, $amount, EntityRegainHealthEvent::CAUSE_EATING);
                         $this->getServer()->getPluginManager()->callEvent($ev);
                         if ($ev->isCancelled()) {
                             return;
                         }
                         --$slot->count;
                         $player->getInventory()->setItemInHand($slot, $player);
                         if ($slot->getId() === Item::MUSHROOM_STEW or $slot->getId() === Item::BEETROOT_SOUP) {
                             $this->getInventory()->addItem(Item::get(Item::BOWL, 0, 1));
                         } elseif ($slot->getId() === Item::RAW_FISH and $slot->getDamage() === 3) {
                             // Pufferfish
                             $player->addEffect(Effect::getEffect(Effect::HUNGER)->setAmplifier(2)->setDuration(15 * 20));
                             $player->addEffect(Effect::getEffect(Effect::POISON)->setAmplifier(3)->setDuration(60 * 20));
                         }
                     }
                     $event->setCancelled();
                     break;
             }
         }
         if ($packet instanceof PlayerActionPacket) {
             if ($packet->action == PlayerActionPacket::ACTION_JUMP) {
                 if ($event->getPlayer()->isSprinting()) {
                     HungerSystem::exhaustion($event->getPlayer(), HungerSystem::JUMPING_WHILE_SPRINTING);
                 } else {
                     if ($event->getPlayer()->isSprinting()) {
                         HungerSystem::exhaustion($event->getPlayer(), HungerSystem::JUMPING);
                     }
                 }
             }
             if ($packet->action == PlayerActionPacket::ACTION_START_SPRINT) {
                 $attribute = AttributeProvider::getInstance()->getAttribute($event->getPlayer());
                 if ($attribute->getHunger() < 6) {
                     $event->setCancelled();
                 }
             }
         }
     }
 }
开发者ID:TDMGamingMC,项目名称:PlayHarder,代码行数:67,代码来源:EventListener.php

示例6: onPlayerItemConsume

 public function onPlayerItemConsume(PlayerItemConsumeEvent $event)
 {
     $event->setCancelled($this->isLogin($event->getPlayer()) ? false : true);
 }
开发者ID:stoastye85,项目名称:Plugins,代码行数:4,代码来源:Login.php

示例7: onPlayerItemConsume

 public function onPlayerItemConsume(PlayerItemConsumeEvent $event)
 {
     $player = $event->getPlayer();
     if (!$this->isLogin($player)) {
         $event->setCancelled();
         return true;
     }
 }
开发者ID:pid011,项目名称:SimpleLogin,代码行数:8,代码来源:EventListener.php

示例8: onItemConsume

 public function onItemConsume(PlayerItemConsumeEvent $event)
 {
     if (!$this->isLoggedIn($event->getPlayer())) {
         $event->setCancelled();
     }
     return;
 }
开发者ID:Edwardthedog2,项目名称:BetterLogin,代码行数:7,代码来源:Main.php

示例9: onPlayerItemConsume

 public function onPlayerItemConsume(\pocketmine\event\player\PlayerItemConsumeEvent $event)
 {
     if (!$this->isLogin($event->getPlayer())) {
         $event->setCancelled();
     }
 }
开发者ID:JungHyun3459,项目名称:PocketMine-Plugins,代码行数:6,代码来源:Login.php

示例10: handleDataPacket


//.........这里部分代码省略.........
                             if ($f < 0.1 or $diff < 5) {
                                 $ev->setCancelled();
                             }
                             $this->server->getPluginManager()->callEvent($ev);
                             if ($ev->isCancelled()) {
                                 $ev->getProjectile()->kill();
                                 $this->inventory->sendContents($this);
                             } else {
                                 $ev->getProjectile()->setMotion($ev->getProjectile()->getMotion()->multiply($ev->getForce()));
                                 if ($this->isSurvival()) {
                                     $this->inventory->removeItem(Item::get(Item::ARROW, 0, 1));
                                     $bow->setDamage($bow->getDamage() + 1);
                                     if ($bow->getDamage() >= 385) {
                                         $this->inventory->setItemInHand(Item::get(Item::AIR, 0, 0));
                                     } else {
                                         $this->inventory->setItemInHand($bow);
                                     }
                                 }
                                 if ($ev->getProjectile() instanceof Projectile) {
                                     $this->server->getPluginManager()->callEvent($projectileEv = new ProjectileLaunchEvent($ev->getProjectile()));
                                     if ($projectileEv->isCancelled()) {
                                         $ev->getProjectile()->kill();
                                     } else {
                                         $ev->getProjectile()->spawnToAll();
                                         $this->level->addSound(new LaunchSound($this), $this->getViewers());
                                     }
                                 } else {
                                     $ev->getProjectile()->spawnToAll();
                                 }
                             }
                         }
                     } elseif ($this->inventory->getItemInHand()->getId() === Item::BUCKET and $this->inventory->getItemInHand()->getDamage() === 1) {
                         //Milk!
                         $this->server->getPluginManager()->callEvent($ev = new PlayerItemConsumeEvent($this, $this->inventory->getItemInHand()));
                         if ($ev->isCancelled()) {
                             $this->inventory->sendContents($this);
                             break;
                         }
                         $pk = new EntityEventPacket();
                         $pk->eid = $this->getId();
                         $pk->event = EntityEventPacket::USE_ITEM;
                         $this->dataPacket($pk);
                         Server::broadcastPacket($this->getViewers(), $pk);
                         if ($this->isSurvival()) {
                             $slot = $this->inventory->getItemInHand();
                             --$slot->count;
                             $this->inventory->setItemInHand($slot);
                             $this->inventory->addItem(Item::get(Item::BUCKET, 0, 1));
                         }
                         $this->removeAllEffects();
                     } else {
                         $this->inventory->sendContents($this);
                     }
                     break;
                 case PlayerActionPacket::ACTION_STOP_SLEEPING:
                     $this->stopSleep();
                     break;
                 case PlayerActionPacket::ACTION_RESPAWN:
                     if ($this->spawned === false or $this->isAlive() or !$this->isOnline()) {
                         break;
                     }
                     if ($this->server->isHardcore()) {
                         $this->setBanned(true);
                         break;
                     }
                     $this->craftingType = 0;
开发者ID:WonderlandPE,项目名称:Steadfast2,代码行数:67,代码来源:Player.php

示例11: onConsume

 public function onConsume(PlayerItemConsumeEvent $ev)
 {
     $this->checkPlenty($ev->getPlayer(), $ev->getItem());
 }
开发者ID:DWWf,项目名称:pocketmine-plugins,代码行数:4,代码来源:CmdPlenty.php

示例12: onDataPacketReceiveEvent

 public function onDataPacketReceiveEvent(DataPacketReceiveEvent $event)
 {
     $packet = $event->getPacket();
     $player = $event->getPlayer();
     if ($packet instanceof EntityEventPacket) {
         if ($player->spawned === \true or $player->blocked === \false or $player->isAlive()) {
             $player->craftingType = 0;
             $player->setDataFlag(Player::DATA_FLAGS, Player::DATA_FLAG_ACTION, \false);
             // TODO: check if this should be true
             switch ($packet->event) {
                 case 9:
                     // Eating
                     $items = [Item::GOLDEN_APPLE => 8];
                     $slot = $player->getInventory()->getItemInHand();
                     if (isset($items[$slot->getId()])) {
                         $this->getServer()->getPluginManager()->callEvent($ev = new PlayerItemConsumeEvent($player, $slot));
                         if ($ev->isCancelled()) {
                             $player->getInventory()->sendContents($player);
                             break;
                         }
                         $pk = new EntityEventPacket();
                         $pk->eid = $player->getId();
                         $pk->event = EntityEventPacket::USE_ITEM;
                         $player->dataPacket($pk);
                         Server::broadcastPacket($player->getViewers(), $pk);
                         $amount = $items[$slot->getId()];
                         if (\is_array($amount)) {
                             $amount = isset($amount[$slot->getDamage()]) ? $amount[$slot->getDamage()] : 0;
                         }
                         $ev = new EntityRegainHealthEvent($player, $amount, EntityRegainHealthEvent::CAUSE_EATING);
                         $this->getServer()->getPluginManager()->callEvent($ev);
                         if ($ev->isCancelled()) {
                             return;
                         }
                         --$slot->count;
                         $player->getInventory()->setItemInHand($slot, $player);
                     }
                     $event->setCancelled();
                     break;
             }
         }
         if ($packet instanceof PlayerActionPacket) {
             if ($packet->action == PlayerActionPacket::ACTION_JUMP) {
                 if ($event->getPlayer()->isSprinting()) {
                     HungerSystem::exhaustion($event->getPlayer(), HungerSystem::JUMPING_WHILE_SPRINTING);
                 } else {
                     if ($event->getPlayer()->isSprinting()) {
                         HungerSystem::exhaustion($event->getPlayer(), HungerSystem::JUMPING);
                     }
                 }
             }
             if ($packet->action == PlayerActionPacket::ACTION_START_SPRINT) {
                 $attribute = AttributeProvider::getInstance()->getAttribute($event->getPlayer());
                 if ($attribute->getHunger() < 6) {
                     $event->setCancelled();
                 }
             }
         }
     }
 }
开发者ID:XEmAX32,项目名称:PlayHarder,代码行数:60,代码来源:EventListener.php

示例13: h_onItemConsume

 public function h_onItemConsume(PlayerItemConsumeEvent $event)
 {
     if (!$this->isLoggedIn()) {
         $event->setCancelled();
     }
 }
开发者ID:LegionPE,项目名称:LegionPE-Eta,代码行数:6,代码来源:Session.php

示例14: onEat

 public function onEat(PlayerItemConsumeEvent $event)
 {
     $user = $this->main->getUserByPlayer($event->getPlayer());
     if ($user === null or !$user->isPlaying()) {
         $event->setCancelled();
     }
 }
开发者ID:GoneTone,项目名称:HereAuth,代码行数:7,代码来源:EventRouter.php

示例15: onDrop

 public function onDrop(PlayerItemConsumeEvent $event)
 {
     if ($event->getItem() instanceof Arrow) {
         if ($event->getItem()->shootingEntity == null) {
             return;
         }
         if ($event->getItem()->shootingEntity instanceof Entities) {
             $event->setCancelled();
         }
     }
 }
开发者ID:EmreTr1,项目名称:rtr,代码行数:11,代码来源:EconomyEntities.php


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