mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-07-04 00:59:51 +00:00
ListCommand: sort output into lexical order
This commit is contained in:
parent
b747899fdd
commit
a60fc4cc28
@ -30,6 +30,8 @@ use function array_filter;
|
|||||||
use function array_map;
|
use function array_map;
|
||||||
use function count;
|
use function count;
|
||||||
use function implode;
|
use function implode;
|
||||||
|
use function sort;
|
||||||
|
use const SORT_STRING;
|
||||||
|
|
||||||
class ListCommand extends VanillaCommand{
|
class ListCommand extends VanillaCommand{
|
||||||
|
|
||||||
@ -52,6 +54,7 @@ class ListCommand extends VanillaCommand{
|
|||||||
}, array_filter($sender->getServer()->getOnlinePlayers(), function(Player $player) use ($sender) : bool{
|
}, array_filter($sender->getServer()->getOnlinePlayers(), function(Player $player) use ($sender) : bool{
|
||||||
return $player->isOnline() and (!($sender instanceof Player) or $sender->canSee($player));
|
return $player->isOnline() and (!($sender instanceof Player) or $sender->canSee($player));
|
||||||
}));
|
}));
|
||||||
|
sort($playerNames, SORT_STRING);
|
||||||
|
|
||||||
$sender->sendMessage(new TranslationContainer("commands.players.list", [count($playerNames), $sender->getServer()->getMaxPlayers()]));
|
$sender->sendMessage(new TranslationContainer("commands.players.list", [count($playerNames), $sender->getServer()->getMaxPlayers()]));
|
||||||
$sender->sendMessage(implode(", ", $playerNames));
|
$sender->sendMessage(implode(", ", $playerNames));
|
||||||
|
Loading…
x
Reference in New Issue
Block a user