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


PHP Level::getPlayers方法代码示例

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


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

示例1: despawnFromAll

 public function despawnFromAll(Level $level = null)
 {
     foreach ($level instanceof Level ? $level->getPlayers() : Server::getInstance()->getOnlinePlayers() as $player) {
         $this->despawnFrom($player);
     }
 }
开发者ID:Tolo0,项目名称:EconomyS,代码行数:6,代码来源:ItemDisplayer.php

示例2: spawnLevelItemCases

 public function spawnLevelItemCases(Level $level)
 {
     if (!isset($this->cases[$level->getName()])) {
         return;
     }
     $ps = $level->getPlayers();
     if (!count($ps)) {
         return;
     }
     foreach (array_keys($this->cases[$level->getName()]) as $cid) {
         $this->sndItemCase($level, $cid, $ps);
     }
 }
开发者ID:flaxues,项目名称:pocketmine-plugins,代码行数:13,代码来源:Main.php

示例3: switchLevelVanish

 /**
  * Allow to switch between levels Vanished!
  * You need to teleport the player to a different level in order to call this event
  *
  * @param Player $player
  * @param Level $origin
  * @param Level $target
  */
 public function switchLevelVanish(Player $player, Level $origin, Level $target)
 {
     if ($origin->getName() !== $target->getName() && $this->isVanished($player)) {
         // This will be used if the specified player has "noPacket" enabled.
         // A temporal check will be used for "the other players".
         $noPacket = $this->hasNoPacket($player);
         // Just as prevention if any player has "noPacket" disabled...
         $pk = new MobEffectPacket();
         $pk->effectId = $this->invisibilityEffect->getId();
         $pk->amplifier = $this->invisibilityEffect->getAmplifier();
         $pk->particles = $this->invisibilityEffect->isVisible();
         $pk->duration = $this->invisibilityEffect->getDuration();
         // Show to origin's players
         $pk->eventId = MobEffectPacket::EVENT_REMOVE;
         foreach ($origin->getPlayers() as $p) {
             if ($p !== $player) {
                 if ($this->isVanished($player)) {
                     if (!$noPacket) {
                         $pk->eid = $player->getId();
                         $p->dataPacket($pk);
                     } else {
                         $p->showPlayer($player);
                     }
                 }
                 if ($this->isVanished($p)) {
                     if (!$this->hasNoPacket($p)) {
                         $pk->eid = $p->getId();
                         $player->dataPacket($pk);
                     } else {
                         $player->showPlayer($p);
                     }
                 }
             }
         }
         // Hide to target's players
         $pk->eventId = MobEffectPacket::EVENT_ADD;
         foreach ($target->getPlayers() as $p) {
             if ($p !== $player) {
                 if ($this->isVanished($player)) {
                     if (!$noPacket) {
                         $pk->eid = $player->getId();
                         $p->dataPacket($pk);
                     } else {
                         $p->hidePlayer($player);
                     }
                 }
                 if ($this->isVanished($p)) {
                     if (!$this->hasNoPacket($p)) {
                         $pk->eid = $p->getId();
                         $player->dataPacket($pk);
                     } else {
                         $player->hidePlayer($p);
                     }
                 }
             }
         }
     }
 }
开发者ID:mwvent,项目名称:WattzEssentialsPE,代码行数:66,代码来源:Loader.php

示例4: updateBlock2

 public function updateBlock2(Block $block, Level $level, $blockType)
 {
     $players = $level->getPlayers();
     foreach ($players as $p) {
         $pk = new UpdateBlockPacket();
         $pk->x = $block->getX();
         $pk->y = $block->getY();
         $pk->z = $block->getZ();
         $pk->block = $blockType;
         $pk->meta = 0;
         $p->dataPacket($pk);
         $level->setBlockIdAt($block->getX(), $block->getY(), $block->getZ(), $blockType);
         $pos = new Position($block->x, $block->y, $block->z);
         $block = $level->getBlock($pos, true);
         $direct = true;
         $update = true;
         $level->setBlock($pos, $block, $direct, $update);
     }
 }
开发者ID:JiangsNetworkAlpha,项目名称:CaptureTheFlag,代码行数:19,代码来源:CTFBlockBuilder.php

示例5: sendLevelInfo

 /**
  * @param CommandSender $sender
  * @param Level $level
  */
 public function sendLevelInfo(CommandSender $sender, Level $level)
 {
     $sender->sendMessage("Name: " . $level->getName());
     $sender->sendMessage("Id: " . $level->getId());
     $sender->sendMessage("Entities: " . count($level->getEntities()));
     $sender->sendMessage("Players: " . count($level->getPlayers()));
     $sender->sendMessage("Tiles: " . count($level->getTiles()));
     $sender->sendMessage("Chunks: " . count($level->getChunks()));
     $sender->sendMessage("Loaders: " . count($level->getLoaders()));
     $sender->sendMessage("Spawn: " . $level->getSafeSpawn()->getFloorX() . ":" . $level->getSafeSpawn()->getFloorY() . ":" . $level->getSafeSpawn()->getFloorZ());
     $sender->sendMessage("Time: " . $level->getTime());
     $sender->sendMessage("Tick-rate: " . $level->getTickRate());
     $sender->sendMessage("Tick-rate-time: " . $level->getTickRateTime());
     $sender->sendMessage("Seed: " . $level->getSeed());
     $sender->sendMessage("Is-auto-saving: " . ($level->getAutoSave() ? TextFormat::GREEN . "yes" : TextFormat::RED . "no"));
     $sender->sendMessage("Is-generated: " . ($level->getServer()->isLevelGenerated($level->getName()) ? TextFormat::GREEN . "yes" : TextFormat::RED . "no"));
     $sender->sendMessage("Is-loaded: " . ($level->getServer()->isLevelLoaded($level->getName()) ? TextFormat::GREEN . "yes" : TextFormat::RED . "no"));
 }
开发者ID:happyexceed,项目名称:PocketMine-Plugins-1,代码行数:22,代码来源:InfoFetcher.php


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