本文整理汇总了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);
}
示例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);
}