This repeats the message 10 or 7 times help!!! Spoiler: code: PHP: <?php/*** ____ _ _ __ __ _ __ __ ____* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \* | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|** This program is free software: you can redistribute it and/or modify* it under the terms of the GNU Lesser General Public License as published by* the Free Software Foundation, either version 3 of the License, or* (at your option) any later version.** @author PocketMine Team* @link http://www.pocketmine.net/***/namespace pocketmine\command\defaults;use pocketmine\command\Command;use pocketmine\command\CommandSender;use pocketmine\command\ConsoleCommandSender;use pocketmine\event\TranslationContainer;use pocketmine\utils\TextFormat;class HelpCommand extends VanillaCommand{ public function __construct($name){ parent::__construct( $name, "%pocketmine.command.help.description", "%commands.help.usage", ["?"] ); $this->setPermission("pocketmine.command.help"); } public function execute(CommandSender $sender, $currentAlias, array $args){ if(!$this->testPermission($sender)){ return true; } if(count($args) === 0){ $command = ""; $pageNumber = 1; }elseif(is_numeric($args[count($args) - 1])){ $pageNumber = (int) array_pop($args); if($pageNumber <= 0){ $pageNumber = 1; } $command = implode(" ", $args); }else{ $command = implode(" ", $args); $pageNumber = 1; } if($sender instanceof ConsoleCommandSender){ $pageHeight = PHP_INT_MAX; }else{ $pageHeight = 5; } if($command === ""){ /** @var Command[][] $commands */ $commands = []; foreach($sender->getServer()->getCommandMap()->getCommands() as $command){ if($command->testPermissionSilent($sender)){ $commands[$command->getName()] = $command; } } ksort($commands, SORT_NATURAL | SORT_FLAG_CASE); $commands = array_chunk($commands, $pageHeight); $pageNumber = (int) min(count($commands), $pageNumber); if($pageNumber < 1){ $pageNumber = 1; } $sender->sendMessage(new TranslationContainer("commands.help.header", [$pageNumber, count($commands)])); if(isset($commands[$pageNumber - 1])){ foreach($commands[$pageNumber - 1] as $command){ $sender->sendMessage(TextFormat::RED . "=========+[CMD]+=========="); $sender->sendMessage(TextFormat::AQUA . "- /Rankup"); $sender->sendMessage(TextFormat::RED . "=========+[CMD]+=========="); } } return true; }else{ if(($cmd = $sender->getServer()->getCommandMap()->getCommand(strtolower($command))) instanceof Command){ if($cmd->testPermissionSilent($sender)){ $message = TextFormat::YELLOW . "--------- " . TextFormat::WHITE . " Help: /" . $cmd->getName() . TextFormat::YELLOW . " ---------\n"; $message .= TextFormat::GOLD . "Description: " . TextFormat::WHITE . $cmd->getDescription() . "\n"; $message .= TextFormat::GOLD . "Usage: " . TextFormat::WHITE . implode("\n" . TextFormat::WHITE, explode("\n", $cmd->getUsage())) . "\n"; $sender->sendMessage($message); return true; } } $sender->sendMessage(TextFormat::RED . "No help for " . strtolower($command)); return true; } }}
$sender-sendMessage(TextFormat::RED . "=========+[CMD]+=========="); $sender-sendMessage(TextFormat::AQUA . "- /Rankup"); $sender-sendMessage(TextFormat::RED . "=========+[CMD]+=========="); Can it be that instead of a command list
You are using foreach(), that will send each page number that you have the messages. And by the way you should remove ksort() and some other functions
Remove PHP: $sender->sendMessage(new TranslationContainer("commands.help.header", [$pageNumber, count($commands)]));
Spoiler: Change by plugin PHP: //For example modding /kick$cmd = "kick";$this->getServer()->getCommandMap()->getCommand($cmd)->setLabel("$cmd_disabled"); /** Prepares for unregister */$this->getServer()->getCommandMap()->getCommand($cmd)->unregister($this->getServer()->getCommandMap()); /** Unregisters from command map */$this->getServer()->getCommandMap()->register($cmd, new ModdedKickCmdClass($this));/** Now you can register the command with an other executor class */
"$cmd_disabled" will be parsed as a variable $cmd_disabled casted to string. You should write $cmd . "_disabled", or simply "$cmd-disabled".
I had made a clean /help modifying plugin some weeks ago, where you can set unlimited pages via the config. You might wanna have a look at that. It's better you do it through a plugin... like this! PHP: public function onHelp(PlayerCommandPreprocessEvent $e){//$this->help = new Config($this->getDataFolder()."help.yml", Config::YAML);$cmd = explode(" ", strtolower($e->getMessage()));$p = $e->getPlayer();if($cmd[0] === "/help" or $cmd[0] === "/?"){// insert code here$e->setCancelled();}} You need to cancel the event so that the server doesn't send player the original vanilla command, help.
Using PlayerCommandPreprocessEvent is bad practic. Why cancelling it indirectly if you're able to do it directly?