Advertisement
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Clear one single command

Comments in 'Plugin Development' started by Inta, Mar 5, 2016.

  1. Inta
    Offline

    Inta Active Member

    Joined:
    Feb 11, 2016
    Posts:
    84
    Minecraft User:
    InstantlyTa
    The "CommandMap" has the "clearCommands" you know.
    It clear all commands that works ok, but i want just one command, and there's no any function for it.
    So the problem is How can i clear just one command ?
  2. Inta
    Offline

    Inta Active Member

    Joined:
    Feb 11, 2016
    Posts:
    84
    Minecraft User:
    InstantlyTa
    Solved it.
    Solution: New function in SimpleCommandMap.php:

    Code:
    public function clearCommand(Command $command, $fallbackPrefix) {
            $command->unregister($this);
            unset($this->knownCommands[$command->getName()]);
    
            $fallbackPrefix = strtolower(trim($fallbackPrefix));
            $aliases = $command->getAliases();
            foreach($aliases as $index => $alias){
                unset($this->knownCommands[$fallbackPrefix . ":" . $alias]);
                unset($this->knownCommands[$alias]);
            }
        }
  3. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,294
    Plugins:
    11
    Minecraft User:
    PEMapModder
    And that means you have to either modify PocketMine source or use reflections.
  4. Inta
    Offline

    Inta Active Member

    Joined:
    Feb 11, 2016
    Posts:
    84
    Minecraft User:
    InstantlyTa
    Yea that's only way .. So sad that PocketMine doesn't have this function..

Share This Page

Advertisement