當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。