unregister command not works

Discussion in 'Development' started by Th3Ang3lo, Dec 30, 2019.

  1. Th3Ang3lo

    Th3Ang3lo Spider Jockey

    Messages:
    33
    GitHub:
    Th3Ang3lo
    i need unregister one command to my server, but it not works. The result is:
    Code:
    Call to a member function unregister() on null
    My code is:
    PHP:
    $commands = ['plot''myplot'];

    foreach (
    $commands as $cmds) {
          
    $map $this->getServer()->getCommandMap();
          
    $map->getCommand($cmds)->unregister($map);
    }
    I use the 3.11.1 api version for 1.14 bedrock edition.
     
  2. Provsnoobgaming

    Provsnoobgaming Witch

    Messages:
    73
    GitHub:
    provsalt
    PHP:
    $map $this->getServer()->getCommandMap();
    $map->unregister($map->getCommand($cmds));
     
    Th3Ang3lo likes this.
  3. Th3Ang3lo

    Th3Ang3lo Spider Jockey

    Messages:
    33
    GitHub:
    Th3Ang3lo
    I get this error:
    Code:
    Argument 1 passed to pocketmine\command\SimpleCommandMap::unregister()
    
     
  4. jasonwynn10

    jasonwynn10 Moderator Poggit Reviewer

    Messages:
    1,449
    GitHub:
    jasonwynn10
    unregister code should be as follows:
    PHP:
    $commandMap->unregister($commandMap->getCommand("commandName"));
     
  5. MalakasPlayzMCPE

    MalakasPlayzMCPE Zombie Pigman

    Messages:
    681
    PHP:
    $commands = ['plot''myplot'];
    $map $this->getServer()->getCommandMap();

    foreach (
    $commands as $cmd){
        
    $map->unregister($map->getCommand($cmd));
    }
    According to what the others said, this should work.
     

Share This Page

  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.