當前位置: 首頁>>代碼示例>>PHP>>正文


PHP PluginCommand::setAliases方法代碼示例

本文整理匯總了PHP中pocketmine\command\PluginCommand::setAliases方法的典型用法代碼示例。如果您正苦於以下問題:PHP PluginCommand::setAliases方法的具體用法?PHP PluginCommand::setAliases怎麽用?PHP PluginCommand::setAliases使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在pocketmine\command\PluginCommand的用法示例。


在下文中一共展示了PluginCommand::setAliases方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: enableCmd

 /**
  * 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);
 }
開發者ID:DWWf,項目名稱:pocketmine-plugins,代碼行數:36,代碼來源:BasicCli.php

示例2: parseYamlCommands

 /**
  * @param Plugin $plugin
  *
  * @return PluginCommand[]
  */
 protected function parseYamlCommands(Plugin $plugin)
 {
     $pluginCmds = [];
     foreach ($plugin->getDescription()->getCommands() as $key => $data) {
         if (strpos($key, ":") !== false) {
             $this->server->getLogger()->critical($this->server->getLanguage()->translateString("pocketmine.plugin.commandError", [$key, $plugin->getDescription()->getFullName()]));
             continue;
         }
         if (is_array($data)) {
             $newCmd = new PluginCommand($key, $plugin);
             if (isset($data["description"])) {
                 $newCmd->setDescription($data["description"]);
             }
             if (isset($data["usage"])) {
                 $newCmd->setUsage($data["usage"]);
             }
             if (isset($data["aliases"]) and is_array($data["aliases"])) {
                 $aliasList = [];
                 foreach ($data["aliases"] as $alias) {
                     if (strpos($alias, ":") !== false) {
                         $this->server->getLogger()->critical($this->server->getLanguage()->translateString("pocketmine.plugin.aliasError", [$alias, $plugin->getDescription()->getFullName()]));
                         continue;
                     }
                     $aliasList[] = $alias;
                 }
                 $newCmd->setAliases($aliasList);
             }
             if (isset($data["permission"])) {
                 $newCmd->setPermission($data["permission"]);
             }
             if (isset($data["permission-message"])) {
                 $newCmd->setPermissionMessage($data["permission-message"]);
             }
             $pluginCmds[] = $newCmd;
         }
     }
     return $pluginCmds;
 }
開發者ID:TylerGames,項目名稱:PocketMine-MP,代碼行數:43,代碼來源:PluginManager.php

示例3: parseYamlCommands

 /**
  * @param Plugin $plugin
  *
  * @return PluginCommand[]
  */
 protected function parseYamlCommands(Plugin $plugin)
 {
     $pluginCmds = [];
     foreach ($plugin->getDescription()->getCommands() as $key => $data) {
         if (strpos($key, ":") !== false) {
             $this->server->getLogger()->critical("Could not load command " . $key . " for plugin " . $plugin->getDescription()->getName());
             continue;
         }
         if (is_array($data)) {
             $newCmd = new PluginCommand($key, $plugin);
             if (isset($data["description"])) {
                 $newCmd->setDescription($data["description"]);
             }
             if (isset($data["usage"])) {
                 $newCmd->setUsage($data["usage"]);
             }
             if (isset($data["aliases"]) and is_array($data["aliases"])) {
                 $aliasList = [];
                 foreach ($data["aliases"] as $alias) {
                     if (strpos($alias, ":") !== false) {
                         $this->server->getLogger()->critical("Could not load alias " . $alias . " for plugin " . $plugin->getDescription()->getName());
                         continue;
                     }
                     $aliasList[] = $alias;
                 }
                 $newCmd->setAliases($aliasList);
             }
             if (isset($data["permission"])) {
                 $newCmd->setPermission($data["permission"]);
             }
             if (isset($data["permission-message"])) {
                 $newCmd->setPermissionMessage($data["permission-message"]);
             }
             $pluginCmds[] = $newCmd;
         }
     }
     return $pluginCmds;
 }
開發者ID:hlogeon,項目名稱:PocketMineJs-MP,代碼行數:43,代碼來源:PluginManager.php


注:本文中的pocketmine\command\PluginCommand::setAliases方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。