59 if(count($args) === 0){
62 }elseif(is_numeric($args[count($args) - 1])){
63 $pageNumber = (int) array_pop($args);
67 $commandName = implode(
" ", $args);
69 $commandName = implode(
" ", $args);
75 if($commandName ===
""){
77 foreach($sender->getServer()->getCommandMap()->getCommands() as $command){
78 if($command->testPermissionSilent($sender)){
79 $commands[$command->getLabel()] = $command;
82 ksort($commands, SORT_NATURAL | SORT_FLAG_CASE);
83 $commands = array_chunk($commands, $pageHeight);
84 $pageNumber = min(count($commands), $pageNumber);
88 $sender->sendMessage(KnownTranslationFactory::commands_help_header((
string) $pageNumber, (
string) count($commands)));
89 $lang = $sender->getLanguage();
90 if(isset($commands[$pageNumber - 1])){
91 foreach($commands[$pageNumber - 1] as $command){
92 $description = $command->getDescription();
93 $descriptionString = $description instanceof
Translatable ? $lang->translate($description) : $description;
94 $sender->sendMessage(TextFormat::DARK_GREEN .
"/" . $command->getLabel() .
": " . TextFormat::RESET . $descriptionString);
100 if(($cmd = $sender->getServer()->getCommandMap()->getCommand(strtolower($commandName))) instanceof
Command){
101 if($cmd->testPermissionSilent($sender)){
102 $lang = $sender->getLanguage();
103 $description = $cmd->getDescription();
104 $descriptionString = $description instanceof
Translatable ? $lang->translate($description) : $description;
105 $sender->sendMessage(KnownTranslationFactory::pocketmine_command_help_specificCommand_header($cmd->getLabel())
106 ->format(TextFormat::YELLOW .
"--------- " . TextFormat::RESET, TextFormat::YELLOW .
" ---------"));
107 $sender->sendMessage(KnownTranslationFactory::pocketmine_command_help_specificCommand_description(TextFormat::RESET . $descriptionString)
108 ->prefix(TextFormat::GOLD));
110 $usage = $cmd->getUsage();
111 $usageString = $usage instanceof
Translatable ? $lang->translate($usage) : $usage;
112 $sender->sendMessage(KnownTranslationFactory::pocketmine_command_help_specificCommand_usage(TextFormat::RESET . implode(
"\n" . TextFormat::RESET, explode(
"\n", $usageString, limit: PHP_INT_MAX)))
113 ->prefix(TextFormat::GOLD));
115 $aliases = $cmd->getAliases();
116 sort($aliases, SORT_NATURAL);
117 $sender->sendMessage(KnownTranslationFactory::pocketmine_command_help_specificCommand_aliases(TextFormat::RESET . implode(
", ", $aliases))
118 ->prefix(TextFormat::GOLD));
123 $sender->sendMessage(KnownTranslationFactory::pocketmine_command_notFound($commandName,
"/help")->prefix(TextFormat::RED));