1. The forums will be archived and moved to a read only mode in about 2 weeks (mid march).

Unregister Help Command

Discussion in 'Development' started by Joao Nunes, Aug 14, 2019.

  1. Joao Nunes

    Joao Nunes Spider Jockey

    Messages:
    30
    GitHub:
    joaonunes12
    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 "/?".
     
  2. VirVolta

    VirVolta Silverfish

    Messages:
    16
    GitHub:
    VirvoltaSurMC
    jasonwynn10 likes this.
  3. Joao Nunes

    Joao Nunes Spider Jockey

    Messages:
    30
    GitHub:
    joaonunes12
    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);

    }
    }
     
  4. Sandertv

    Sandertv Zombie Pigman Poggit Reviewer

    Messages:
    786
    GitHub:
    Sandertv
    It was just mentioned that those commands are client-side. You cannot overwrite them, no matter how hard you try.
     
  5. Muqsit

    Muqsit Chicken

    Messages:
    1,548
    GitHub:
    muqsit
    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.
     
  6. Joao Nunes

    Joao Nunes Spider Jockey

    Messages:
    30
    GitHub:
    joaonunes12
    Musquit, I tried to put the alias in plugin.yml and afther when i register commandMap, Does not work in both work, but thanks.
     
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.