diff --git a/src/pocketmine/command/defaults/BanListCommand.php b/src/pocketmine/command/defaults/BanListCommand.php index 659d6b9d0..846e7734f 100644 --- a/src/pocketmine/command/defaults/BanListCommand.php +++ b/src/pocketmine/command/defaults/BanListCommand.php @@ -25,6 +25,7 @@ namespace pocketmine\command\defaults; use pocketmine\command\CommandSender; use pocketmine\event\TranslationContainer; +use pocketmine\permission\BanEntry; class BanListCommand extends VanillaCommand{ @@ -58,11 +59,10 @@ class BanListCommand extends VanillaCommand{ $args[0] = "players"; } - $message = ""; $list = $list->getEntries(); - foreach($list as $entry){ - $message .= $entry->getName() . ", "; - } + $message = implode(", ", array_map(function(BanEntry $entry){ + return $entry->getName(); + }, $list)); if($args[0] === "ips"){ $sender->sendMessage(new TranslationContainer("commands.banlist.ips", [count($list)])); @@ -70,7 +70,7 @@ class BanListCommand extends VanillaCommand{ $sender->sendMessage(new TranslationContainer("commands.banlist.players", [count($list)])); } - $sender->sendMessage(substr($message, 0, -2)); + $sender->sendMessage($message); return true; } diff --git a/src/pocketmine/command/defaults/WhitelistCommand.php b/src/pocketmine/command/defaults/WhitelistCommand.php index 44d71eb40..05583b211 100644 --- a/src/pocketmine/command/defaults/WhitelistCommand.php +++ b/src/pocketmine/command/defaults/WhitelistCommand.php @@ -70,14 +70,12 @@ class WhitelistCommand extends VanillaCommand{ return true; case "list": - $result = ""; - $count = 0; - foreach($sender->getServer()->getWhitelisted()->getAll(true) as $player){ - $result .= $player . ", "; - ++$count; - } + $entries = $sender->getServer()->getWhitelisted()->getAll(true); + $result = implode($entries, ", "); + $count = count($entries); + $sender->sendMessage(new TranslationContainer("commands.whitelist.list", [$count, $count])); - $sender->sendMessage(substr($result, 0, -2)); + $sender->sendMessage($result); return true;