pocketmine\command\PluginCommand::setExecutor PHP Method

setExecutor() public method

public setExecutor ( pocketmine\command\CommandExecutor $executor )
$executor pocketmine\command\CommandExecutor
    public function setExecutor(CommandExecutor $executor)
    {
        $this->executor = $executor != null ? $executor : $this->owningPlugin;
    }

Usage Example

Exemplo n.º 1
0
 /**
  * Register this class as a command.
  *
  * @param str $cmd - command to register
  * @param mixed[] $yaml - options for command
  */
 public function enableCmd($cmd, $yaml)
 {
     $newCmd = new PluginCommand($cmd, $this->owner);
     if (isset($yaml["description"])) {
         $newCmd->setDescription($yaml["description"]);
     }
     if (isset($yaml["usage"])) {
         $newCmd->setUsage($yaml["usage"]);
     }
     if (isset($yaml["aliases"]) and is_array($yaml["aliases"])) {
         $aliasList = [];
         foreach ($yaml["aliases"] as $alias) {
             if (strpos($alias, ":") !== false) {
                 $this->owner->getLogger()->info("Unable to load alias {$alias}");
                 continue;
             }
             $aliasList[] = $alias;
         }
         $newCmd->setAliases($aliasList);
     }
     if (isset($yaml["permission"])) {
         $newCmd->setPermission($yaml["permission"]);
     }
     if (isset($yaml["permission-message"])) {
         $newCmd->setPermissionMessage($yaml["permission-message"]);
     }
     $newCmd->setExecutor($this);
     $cmdMap = $this->owner->getServer()->getCommandMap();
     $cmdMap->register($this->owner->getDescription()->getName(), $newCmd);
 }
All Usage Examples Of pocketmine\command\PluginCommand::setExecutor