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