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


PHP PlayerItemConsumeEvent::setCancelled方法代码示例

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


在下文中一共展示了PlayerItemConsumeEvent::setCancelled方法的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: 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

示例3: onPlayerEat

 public function onPlayerEat(pic $ev)
 {
     $p = $ev->getPlayer();
     $i = $ev->getItem();
     switch ($this->phase) {
         case 0:
             //Waiting in the lobby
         //Waiting in the lobby
         case 1:
             //Starting the game
             $ev->setCancelled();
             break;
         case 2:
         case 3:
             if ($i->getId() == Item::GOLDEN_APPLE) {
                 $p->addEffect(Effect::getEffect(6)->setAmplifier(1)->setDuration(4));
             }
             break;
     }
 }
开发者ID:nao20010128nao,项目名称:UltraHardCore,代码行数:20,代码来源:UHC.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: onConsume

 public function onConsume(PlayerItemConsumeEvent $event)
 {
     $session = $this->main->getSession($event->getPlayer());
     if (!$session instanceof Session) {
         $event->setCancelled();
         return;
     }
     if ($session->onConsume($event) === false) {
         $event->setCancelled();
     }
 }
开发者ID:legoboy0215,项目名称:LegionPE-Theta-Base,代码行数:11,代码来源:SessionEventListener.php

示例6: onPlayerItemConsume

 public function onPlayerItemConsume(PlayerItemConsumeEvent $event)
 {
     if (!$this->isValidPlayer($event->getPlayer())) {
         return;
     }
     if ($this->players[$event->getPlayer()->getName()]->getSkillByItem($event->getItem()) !== null) {
         $event->setCancelled();
     }
 }
开发者ID:HelloWorld017,项目名称:ToAruPG,代码行数:9,代码来源:ToAruPG.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: onPlayerItemConsume

 public function onPlayerItemConsume(PlayerItemConsumeEvent $event)
 {
     if (isset($this->needAuth[$event->getPlayer()->getName()])) {
         $event->setCancelled();
         $this->deauthenticatePlayer($event->getPlayer());
     }
 }
开发者ID:HerO-0110,项目名称:EmailAuth,代码行数:7,代码来源:EmailAuth.php

示例9: onItemConsume

 public function onItemConsume(PlayerItemConsumeEvent $event)
 {
     if ($this->plugin->getConfig()->getAll()["block-all-events"]) {
         if (!ServerAuth::getAPI()->isPlayerRegistered($event->getPlayer()->getName()) || !ServerAuth::getAPI()->isPlayerAuthenticated($event->getPlayer())) {
             $event->setCancelled(true);
         }
     }
 }
开发者ID:RedstoneAlmeida,项目名称:SliceAuth,代码行数:8,代码来源:EventListener.php

示例10: h_onItemConsume

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

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

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

示例13: onPlayerItemConsume

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

示例14: onPlayerItemConsume

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

示例15: handleDataPacket


//.........这里部分代码省略.........
                         $this->level->setBlock($block, new Air());
                         break;
                     }
                     $this->lastBreak = microtime(true);
                     break;
                 case PlayerActionPacket::ACTION_ABORT_BREAK:
                     $this->lastBreak = PHP_INT_MAX;
                     break;
                 case PlayerActionPacket::ACTION_RELEASE_ITEM:
                     if ($this->startAction > -1 and $this->getDataFlag(self::DATA_FLAGS, self::DATA_FLAG_ACTION)) {
                         if ($this->inventory->getItemInHand()->getId() === Item::BOW) {
                             $bow = $this->inventory->getItemInHand();
                             if ($this->isSurvival() and !$this->inventory->contains(Item::get(Item::ARROW, null))) {
                                 $this->inventory->sendContents($this);
                                 break;
                             }
                             $arrow = false;
                             foreach ($this->inventory->getContents() as $item) {
                                 if ($item->getId() == Item::ARROW) {
                                     $arrow = $item;
                                 }
                             }
                             if ($arrow === false and $this->isCreative()) {
                                 $arrow = Item::get(Item::ARROW, 0, 1);
                             } elseif ($arrow === false) {
                                 break;
                             }
                             $nbt = new CompoundTag("", ["Pos" => new ListTag("Pos", [new DoubleTag("", $this->x), new DoubleTag("", $this->y + $this->getEyeHeight()), new DoubleTag("", $this->z)]), "Motion" => new ListTag("Motion", [new DoubleTag("", -sin($this->yaw / 180 * M_PI) * cos($this->pitch / 180 * M_PI)), new DoubleTag("", -sin($this->pitch / 180 * M_PI)), new DoubleTag("", cos($this->yaw / 180 * M_PI) * cos($this->pitch / 180 * M_PI))]), "Rotation" => new ListTag("Rotation", [new FloatTag("", $this->yaw), new FloatTag("", $this->pitch)]), "Fire" => new ShortTag("Fire", $this->isOnFire() ? 45 * 60 : 0), "Potion" => new ShortTag("Potion", $arrow->getDamage())]);
                             $diff = $this->server->getTick() - $this->startAction;
                             $p = $diff / 20;
                             $f = min(($p ** 2 + $p * 2) / 3, 1) * 2;
                             $ev = new EntityShootBowEvent($this, $bow, Entity::createEntity("Arrow", $this->chunk, $nbt, $this, $f == 2 ? true : false), $f);
                             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, $arrow->getDamage(), 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()));
开发者ID:robske110,项目名称:ClearSky,代码行数:67,代码来源:Player.php


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