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


PHP Player::setDataFlag方法代码示例

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


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

示例1: setVanish

 /**
  * Set the Vanish mode on or off
  *
  * @param Player $player
  * @param bool $state
  * @param bool $noPacket
  * @return bool
  */
 public function setVanish(Player $player, $state, $noPacket = false)
 {
     if (!is_bool($state)) {
         return false;
     }
     if ($this->invisibilityEffect === null) {
         $effect = new Effect(Effect::INVISIBILITY, "Vanish", 127, 131, 146);
         $effect->setDuration(1728000);
         // 24 hours... Well... No one will play more than this, so I think its OK xD
         $this->invisibilityEffect = $effect;
     }
     $this->getServer()->getPluginManager()->callEvent($ev = new PlayerVanishEvent($this, $player, $state, $noPacket));
     if ($ev->isCancelled()) {
         return false;
     }
     $state = $ev->willVanish();
     $player->setDataFlag(Entity::DATA_FLAGS, Entity::DATA_FLAG_INVISIBLE, $state);
     $player->setDataProperty(Entity::DATA_SHOW_NAMETAG, Entity::DATA_TYPE_BYTE, $state ? 0 : 1);
     /** @var Player[] $pl */
     $pl = [];
     foreach ($player->getLevel()->getPlayers() as $p) {
         if ($state || !$state && !in_array($p->getName(), $ev->getHiddenFor())) {
             $pl[] = $p;
         }
     }
     $noPacket = $ev->noPacket();
     if ($this->isVanished($player) && $ev->noPacket() !== ($priority = $this->hasNoPacket($player))) {
         $noPacket = $priority;
     }
     if (!$noPacket) {
         if (!$state) {
             $pk = new MobEffectPacket();
             $pk->eid = $player->getId();
             $pk->eventId = MobEffectPacket::EVENT_REMOVE;
             $pk->effectId = $this->invisibilityEffect->getId();
         } else {
             $pk = new MobEffectPacket();
             $pk->eid = $player->getId();
             $pk->effectId = $this->invisibilityEffect->getId();
             $pk->amplifier = $this->invisibilityEffect->getAmplifier();
             $pk->particles = $this->invisibilityEffect->isVisible();
             $pk->duration = $this->invisibilityEffect->getDuration();
             $pk->eventId = MobEffectPacket::EVENT_ADD;
         }
         $this->getServer()->broadcastPacket($pl, $pk);
     } else {
         if (!$state) {
             foreach ($pl as $p) {
                 $p->showPlayer($player);
             }
         } else {
             foreach ($pl as $p) {
                 $p->hidePlayer($player);
             }
         }
     }
     $this->getSession($player)->setVanish($state, !$state ? $ev->noPacket() : $noPacket);
     return true;
 }
开发者ID:mwvent,项目名称:WattzEssentialsPE,代码行数:67,代码来源:Loader.php

示例2: initialHuman

 private function initialHuman(Player $player)
 {
     $player->setDataFlag($player::DATA_PLAYER_FLAGS, $player::DATA_PLAYER_FLAG_SLEEP, false);
     $player->setDataProperty($player::DATA_PLAYER_BED_POSITION, $player::DATA_TYPE_POS, [0, 0, 0]);
     $inventory = new PlayerInventory($player);
     $this->setPrivateVariableData($player, 'inventory', $inventory);
     if ($player instanceof Player) {
         $player->addWindow($inventory, 0);
     }
     if (!$player instanceof Player) {
         if (isset($player->namedtag->NameTag)) {
             $player->setNameTag($player->namedtag["NameTag"]);
         }
         if (isset($player->namedtag->Skin) and $player->namedtag->Skin instanceof CompoundTag) {
             $player->setSkin($player->namedtag->Skin["Data"], $player->namedtag->Skin["Slim"] > 0);
         }
         $this->setPrivateVariableData($player, 'uuid', UUID::fromData($player->getId(), $player->getSkinData(), $player->getNameTag()));
     }
     if (isset($player->namedtag->Inventory) and $player->namedtag->Inventory instanceof ListTag) {
         foreach ($player->namedtag->Inventory as $item) {
             if ($item["Slot"] >= 0 and $item["Slot"] < 9) {
                 // Hotbar
                 $player->inventory->setHotbarSlotIndex($item["Slot"], isset($item["TrueSlot"]) ? $item["TrueSlot"] : -1);
             } elseif ($item["Slot"] >= 100 and $item["Slot"] < 104) {
                 // Armor
                 $player->getInventory()->setItem($player->getInventory()->getSize() + $item["Slot"] - 100, NBT::getItemHelper($item));
             } else {
                 $player->getInventory()->setItem($item["Slot"] - 9, NBT::getItemHelper($item));
             }
         }
     }
     $this->initialEntity($player);
 }
开发者ID:organization,项目名称:SpawningPool,代码行数:33,代码来源:AuthenticateCallback.php

示例3: disableSneak

 public function disableSneak(Player $player)
 {
     unset($this->players[$player->getName()]);
     $player->setDataFlag(Entity::DATA_FLAGS, Entity::DATA_FLAG_SNEAKING, false);
 }
开发者ID:GmWM,项目名称:PocketMine-MP-Plugins,代码行数:5,代码来源:Main.php

示例4: disableSneak

 public function disableSneak(Player $player)
 {
     unset($this->players[$player->getName()]);
     $player->setDataFlag(Entity::DATA_FLAGS, Entity::DATA_FLAG_SNEAKING, false);
     $player->sendMessage(TextFormat::GOLD . "You have Disabled sneaking!");
 }
开发者ID:HeroGamingZ,项目名称:PocketMine-MP-Plugins,代码行数:6,代码来源:Main.php


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