Add ability to unregister a command completely, close #1229 (#1464)

This commit is contained in:
JackNoordhuis 2017-10-13 21:55:36 +11:00 committed by Dylan K. Taylor
parent eeea4fa06a
commit 060426ff12

View File

@ -174,6 +174,23 @@ class SimpleCommandMap implements CommandMap{
return $registered;
}
/**
* @param Command $command
*
* @return bool
*/
public function unregister(Command $command) : bool{
foreach($this->knownCommands as $lbl => $cmd){
if($cmd === $command){
unset($this->knownCommands[$lbl]);
}
}
$command->unregister($this);
return true;
}
/**
* @param Command $command
* @param bool $isAlias