當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。