当前位置: 首页>>代码示例>>PHP>>正文


PHP Command::testPermissionSilent方法代码示例

本文整理汇总了PHP中pocketmine\command\Command::testPermissionSilent方法的典型用法代码示例。如果您正苦于以下问题:PHP Command::testPermissionSilent方法的具体用法?PHP Command::testPermissionSilent怎么用?PHP Command::testPermissionSilent使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在pocketmine\command\Command的用法示例。


在下文中一共展示了Command::testPermissionSilent方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: testPermissionSilent

 public function testPermissionSilent(CommandSender $sender)
 {
     if ($sender instanceof Position) {
         if ($this->getName() === "f" and !$this->main->isFactionWorld($sender->getLevel()->getName())) {
             return false;
         }
     }
     return parent::testPermissionSilent($sender);
 }
开发者ID:MCPEGamerJPatGitHub,项目名称:PocketFactions,代码行数:9,代码来源:SubcommandMap.php

示例2: onCommand

 public function onCommand(CommandSender $sender, Command $cmd, $alias, array $args)
 {
     if (!isset($args[0])) {
         return false;
     }
     $k = $sender instanceof Player ? $sender->getID() : get_class($sender);
     switch ($subcmd = array_shift($args)) {
         case "stop":
             if (!isset($this->stack[$k])) {
                 $sender->sendMessage("You don't have a recording macro to stop!");
                 break;
             }
             if (!isset($args[0])) {
                 $sender->sendMessage("Usage: /macro stop <name>");
                 $sender->sendMessage("Don't worry, this command will not be recorded.");
                 break;
             }
             if (strtolower($name = array_shift($args)) === "ng") {
                 $sender->sendMessage("This NG macro has been discarded.");
                 // continue to run: unset stack
             } else {
                 if ($this->getMacro($name) !== false) {
                     $sender->sendMessage("There is already a macro called \"{$name}\"!");
                     $sender->sendMessage("Don't worry, this command will not be recorded.");
                     break;
                 }
                 $success = $this->saveMacro($name, $this->stack[$k]);
                 if (!$success) {
                     $sender->sendMessage("Unable to create file. Perhaps \"{$name}\" is not a valid filename?");
                     $sender->sendMessage("Don't worry, this command will not be recorded.");
                     break;
                 }
                 // continue to run: unset stack
             }
             if (isset($this->stack[$id = $k])) {
                 // copied xD
                 unset($this->stack[$id]);
                 // avoid bugs if the entity ID gets reused
             }
             if (isset($this->paused[$id])) {
                 unset($this->stack[$id]);
             }
             $sender->sendMessage("You have successfully saved macro {$name}.");
             break;
         case "start":
             if (!$sender->hasPermission("simplemacros.record")) {
                 $sender->sendMessage("You don't have permission to record a macro.");
                 return true;
             }
             if (isset($this->stack[$k])) {
                 $sender->sendMessage("You have already started recording a macro!");
                 return true;
             }
             $this->stack[$k] = "";
             $sender->sendMessage("You are now recording a macro.");
             break;
         case "pause":
             if (!isset($this->stack[$k])) {
                 $sender->sendMessage("You are not recording a macro!");
                 return true;
             }
             $this->paused[$k] = true;
             $sender->sendMessage("Your macro is now paused.");
             $sender->sendMessage("Don't worry, this command will not be recorded.");
             break;
         case "resume":
             if (!isset($this->paused[$k]) or $this->paused[$k] === false) {
                 $sender->sendMessage("You do not have a paused recording macro!");
                 $sender->sendMessage("Don't worry, this command will not be recorded.");
                 return true;
             }
             $this->paused[$k] = false;
             $sender->sendMessage("You have now resumed your macro.");
             break;
         case "sudo":
             if (!$sender->hasPermission("simplemacros.sudo")) {
                 $sender->sendMessage("You don't have permision to sudo others with a macro.");
                 return true;
             }
             if (!isset($args[1])) {
                 $sender->sendMessage("Usage: /macro sudo <macro name> <player name> [-op]");
                 return true;
             }
             $macro = $this->getMacro($name = array_shift($args));
             if ($macro === false) {
                 $sender->sendMessage("{$macro} doesn't exist!");
                 return true;
             }
             if (!($p = $this->getServer()->getPlayer($args[1])) instanceof Player) {
                 $sender->sendMessage("Player {$args['1']} not found!");
                 return true;
             }
             if (isset($args[2]) and $args[2] === "-op" and !$sender->hasPermission("simplemacros.opsudo")) {
                 $sender->sendMessage("You do not have permission to op-sudo a player with a macro!");
             }
             foreach ($macro as $rline) {
                 $line = trim($rline);
                 if (isset($args[2]) and $args[2] === "-op") {
                     if (($rcmd = $this->getServer()->getCommandMap()->getCommand(strstr($line, " ", true))) instanceof Command) {
                         if (!$cmd->testPermissionSilent($p) and $cmd->testPermissionSilent($sender)) {
//.........这里部分代码省略.........
开发者ID:barnseyminesuk,项目名称:Small-ZC-Plugins,代码行数:101,代码来源:Main.php


注:本文中的pocketmine\command\Command::testPermissionSilent方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。