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

Unregistering commands

Discussion in 'Development' started by SavionLegendZzz, May 12, 2017.

  1. SavionLegendZzz

    SavionLegendZzz Slime

    Messages:
    75
    GitHub:
    savionlegends
    Ok so i am unregistering commands and i have come upon the issue where it does not unregister the command aliases how to go about fixing this ? here is my code(taken from LegionPE-theta):
    PHP:
    public static function registerAll(Main $mainCommandMap $map){
            
    $cmds = ["tell","help","me","?","msg"];
            foreach(
    $cmds as $cmd){
                
    self::unregisterCommand($map$cmd);
            }
            
    $map->registerAll("c", [
                new 
    TellCommand($main"tell""Send a player a private message"null, ["msg","w","pm"]),
                new 
    LangCommand($main"lang""Change your language preference!"null),
                new 
    MeCommand($main"me""Shout yourself out!"null),
                new 
    HelpCommand($main"help""See the list of commands!"null, ["?"])]);
        }
     
  2. TheDiamondYT

    TheDiamondYT Zombie

    Messages:
    298
    GitHub:
    TheDiamondYT1
    Show the unregisterCommand function, or that example is useless.
     
  3. SavionLegendZzz

    SavionLegendZzz Slime

    Messages:
    75
    GitHub:
    savionlegends
    oh yes sorry(also taken from LegionPE-theta):
    PHP:
    public static function unregisterCommand(CommandMap $map$name){
            
    $cmd $map->getCommand($name);
            if(
    $cmd instanceof Command){
                
    $cmd->setLabel($name "_deprecated");
                
    $cmd->unregister($map);
                return 
    true;
            }
            return 
    false;
        }
     
  4. 0x15f

    0x15f Baby Zombie

    Messages:
    145
    GitHub:
    0x15f
    $command->getAliases() and unregister them.
     
  5. Sandertv

    Sandertv Zombie Pigman Poggit Reviewer

    Messages:
    786
    GitHub:
    Sandertv
    The _deprecated should be replaced with _disabled, at least, as far as I know.
     
  6. SavionLegendZzz

    SavionLegendZzz Slime

    Messages:
    75
    GitHub:
    savionlegends
    Tired this and still it did not work
     
  7. 0x15f

    0x15f Baby Zombie

    Messages:
    145
    GitHub:
    0x15f
    Make sure the map is an instance of pocketmine\command\SimpleCommandMap and it should work.
     
  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.