pocketmine\Server::getCommandAliases PHP Method

getCommandAliases() public method

public getCommandAliases ( ) : string[]
return string[]
    public function getCommandAliases()
    {
        $section = $this->getProperty("aliases");
        $result = [];
        if (is_array($section)) {
            foreach ($section as $key => $value) {
                $commands = [];
                if (is_array($value)) {
                    $commands = $value;
                } else {
                    $commands[] = $value;
                }
                $result[$key] = $commands;
            }
        }
        return $result;
    }

Usage Example

Exemplo n.º 1
0
 /**
  * @return void
  */
 public function registerServerAliases()
 {
     $values = $this->server->getCommandAliases();
     foreach ($values as $alias => $commandStrings) {
         if (strpos($alias, ":") !== false or strpos($alias, " ") !== false) {
             $this->server->getLogger()->warning(Terminal::$COLOR_GREEN . "plugin> " . Terminal::$COLOR_YELLOW . "Could not register alias '{$alias}' because it contains illegal characters");
             continue;
         }
         $targets = [];
         $bad = "";
         foreach ($commandStrings as $commandString) {
             $args = explode(" ", $commandString);
             $command = $this->getCommand($args[0]);
             if ($command === null) {
                 if (strlen($bad) > 0) {
                     $bad .= ", ";
                 }
                 $bad .= $commandString;
             } else {
                 $targets[] = $commandString;
             }
         }
         if (strlen($bad) > 0) {
             $this->server->getLogger()->warning(Terminal::$COLOR_GREEN . "plugin> " . Terminal::$COLOR_YELLOW . "Could not register alias '{$alias}' because it contains commands that do not exist: {$bad}");
             continue;
         }
         //These registered commands have absolute priority
         if (count($targets) > 0) {
             $this->knownCommands[strtolower($alias)] = new FormattedCommandAlias(strtolower($alias), $targets);
         } else {
             unset($this->knownCommands[strtolower($alias)]);
         }
     }
 }
All Usage Examples Of pocketmine\Server::getCommandAliases
Server