public function format(Server $server, CommandSender $sender, $name, array $args) { $result = []; foreach ($server->getOnlinePlayers() as $p) { if (CmdSel::checkSelectors($args, $sender, $p)) { $result[] = $p->getName(); } } return $result; }
public function format(Server $server, CommandSender $sender, $name, array $args) { if (!$sender instanceof Position) { return null; } /** @var CommandSender|Position $sender */ $players = CmdSel::getNearestPlayers($sender, [function (Player $player) use($args, $sender) { return CmdSel::checkSelectors($args, $sender, $player); }]); /** @var Player $rand */ $rand = array_rand($players); return $rand->getName(); }
public function format(Server $server, CommandSender $sender, $name, array $args) { $players = []; foreach ($sender->getServer()->getOnlinePlayers() as $player) { if ($player === $sender) { continue; } if (CmdSel::checkSelectors($args, $sender, $player)) { continue; } $players[] = $player; } if (count($players) === 0) { return false; } /** @var \pocketmine\Player $rand */ $rand = array_rand($players); return $rand; }