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


PHP CommandSender::canSee方法代码示例

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


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

示例1: onCommand

 public function onCommand(CommandSender $sender, Command $cmd, $label, array $args)
 {
     if ($cmd->getName() != "players") {
         return false;
     }
     $tab = [[mc::_("Player"), mc::_("World"), mc::_("Pos"), mc::_("Health"), mc::_("Mode")]];
     $cnt = 0;
     foreach ($this->owner->getServer()->getOnlinePlayers() as $player) {
         if (!$player->isOnline() || $sender instanceof Player && !$sender->canSee($player)) {
             continue;
         }
         $pos = $player->getPosition();
         $j = count($tab);
         $mode = substr(MPMU::gamemodeStr($player->getGamemode()), 0, 4);
         $tab[] = [$player->getName(), $player->getLevel()->getName(), $pos->getFloorX() . "," . $pos->getFloorY() . "," . $pos->getFloorZ(), intval($player->getHealth()) . '/' . intval($player->getMaxHealth()), $mode];
         ++$cnt;
     }
     if (!$cnt) {
         $sender->sendMessage(TextFormat::RED . mc::_("Nobody is on-line at the moment"));
         return true;
     }
     $tab[0][0] = mc::_("Players: %1%", $cnt);
     $pageNumber = $this->getPageNumber($args);
     return $this->paginateTable($sender, $pageNumber, $tab);
 }
开发者ID:Gabriel865,项目名称:pocketmine-plugins,代码行数:25,代码来源:CmdPlayers.php

示例2: onCommand

 public function onCommand(CommandSender $sender, Command $cmd, $label, array $args)
 {
     if ($cmd->getName() != "ops") {
         return false;
     }
     $txt = [""];
     $pageNumber = $this->getPageNumber($args);
     $cnt = 0;
     foreach (array_keys($this->owner->getServer()->getOps()->getAll()) as $opname) {
         $p = $this->owner->getServer()->getPlayer($opname);
         if ($p && ($p->isOnline() && (!$sender instanceof Player || $sender->canSee($p)))) {
             ++$cnt;
             $txt[] = TextFormat::BLUE . mc::_("%1% (online)", $opname);
         } else {
             $txt[] = TextFormat::RED . "{$opname}";
         }
     }
     $txt[0] = mc::_("Server Ops (Online:%1%)", $cnt);
     return $this->paginateText($sender, $pageNumber, $txt);
 }
开发者ID:Gabriel865,项目名称:pocketmine-plugins,代码行数:20,代码来源:CmdOps.php


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