I'm trying to unregister the "help" command, I did the following: $this->getServer()->getCommandMap()->getCommand("help")->setLabel("help_disabled"); $this->getServer()->getCommandMap()->getCommand("help")->unregister($this->getServer()->getCommandMap()); $this->getServer()->getCommandMap()->register("HelpCustom", new Help($this)); $this->getServer()->getCommandMap()->register("HelpCustom", new Help($this), "?"); I'm trying to do / help on Form api, this code unregister only "./help" and "./?" within the game, I need to unregister "/help" and "/?".
The command /help or /? is a command that is sent from the client and not pocketmine so pocketmine cannot unload. But we can cancel the execution of the command with the PlayerCommandPreprocessEvent event for more info https://github.com/pmmp/PocketMine-MP/blob/stable/src/pocketmine/event/player/PlayerCommandPreprocessEvent.php
Same error, block "./help" and "./?" but not block "/help" and "/?". public function onCmd(PlayerCommandPreprocessEvent $ev) { $cmd = trim($ev->getMessage(), "/"); $ex = explode(" ", $cmd); if($ex[0] == "help" or $ex[0] == "?"){ $ev->setCancelled(true); } }
It was just mentioned that those commands are client-side. You cannot overwrite them, no matter how hard you try.
It is generated on the client's side which renders pm's HelpCommand useless. But the unable to override issue is a server-sided limitation: https://github.com/pmmp/PocketMine-MP/blob/stable/src/pocketmine/Player.php#L719 I think a command with the alias "help" (and not the name "help") can still override it, not sure.
Musquit, I tried to put the alias in plugin.yml and afther when i register commandMap, Does not work in both work, but thanks.