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


PHP CommandSender::setGamemode方法代码示例

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


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

示例1: onCommand

 public function onCommand(CommandSender $sender, Command $cmd, $label, array $args)
 {
     $cfg = $this->getConfig();
     $defgm = $cfg->get("Default-Game-Mode");
     $tptosp = $cfg->get("Teleport-To-Spawn");
     if (isset($args[0])) {
         switch ($args[0]) {
             case "on":
                 $sender->setGamemode(3);
                 $sender->sendMessage(TextFormat::GREEN . "You are now a Spectator!");
                 $this->getLogger()->info($sender->getName() . " Has changed his gamemode to Spectator");
                 return true;
             case "off":
                 $sender->setGamemode($defgm);
                 $sender->sendMessage(TextFormat::YELLOW . "You are no longer Espectator");
                 if ($tptosp === true) {
                     $sender->teleport($this->getServer()->getDefaultLevel()->getSpawn());
                 }
                 return true;
         }
     }
     return false;
 }
开发者ID:TonyDroidd,项目名称:Spectator,代码行数:23,代码来源:Main.php

示例2: onCommand


//.........这里部分代码省略.........
                                         $p->setGameMode(0);
                                     }
                                     $this->stopGame($this->getConfig()->get('aworld'));
                                     //stop the game
                                 }
                             }
                             return true;
                         } else {
                             $sender->sendMessage("You are not in the SkyWars world.");
                             return true;
                         }
                     } else {
                         $sender->sendMessage("You haven't the permission to run this command.");
                         return true;
                     }
                     break;
                 case "stat":
                     if ($sender->hasPermission("skywars.command.stat") or $sender->hasPermission("skywars.command") or $sender->hasPermission("skywars")) {
                         if (!isset($args[1])) {
                             $player = $sender->getName();
                             $deaths = $this->points->get($player)[0];
                             $kills = $this->points->get($player)[1];
                             $points = $this->points->get($player)[2];
                             $sender->sendMessage("You have " . $deaths . " deaths, " . $kills . " kills and " . $points . " points.");
                             return true;
                         } else {
                             $player = $args[1];
                             $deaths = $this->points->get($player)[0];
                             $kills = $this->points->get($player)[1];
                             $points = $this->points->get($player)[2];
                             $sender->sendMessage($player . " has " . $deaths . " deaths, " . $kills . " kills and " . $points . " points.");
                             return true;
                         }
                     } else {
                         $sender->sendMessage("You haven't the permission to run this command.");
                         return true;
                     }
                     break;
                 case "spawnpos":
                     if ($sender->hasPermission("skywars.command.pos") or $sender->hasPermission("skywars.command") or $sender->hasPermission("skywars")) {
                         $x = $sender->getX();
                         $y = $sender->getY();
                         //get coordinates and store in variables
                         $z = $sender->getZ();
                         $this->getConfig()->set('spawns', array($x, $y, $z));
                         $sender->sendMessage("Spawn position set to: " . $x . ", " . $y . ", " . $z . ", level: " . $sender->getLevel()->getName());
                         return true;
                     } else {
                         $sender->sendMessage("You haven't the permission to run this command.");
                         return true;
                     }
                     break;
                 case "skiptime":
                     if ($sender->hasPermission("skywars.command.skiptime") or $sender->hasPermission("skywars.command") or $sender->hasPermission("skywars")) {
                         if ($this->aplayers >= $this->getConfig()->get("minplayers")) {
                             $this->startGame($sender->getLevel()->getName());
                             //start game on the sender level
                             $sender->sendMessage("You started the game skipping the waiting time!");
                             return true;
                         } else {
                             $sender->sendMessage("There are less than 3 players, you can't start the game yet.");
                             return true;
                         }
                     } else {
                         $sender->sendMessage("You haven't the permission to run this command.");
                         return true;
                     }
                     break;
                 case "left":
                     if ($sender->hasPermission("skywars.command.left") or $sender->hasPermission("skywars.command") or $sender->hasPermission("skywars")) {
                         if ($sender->getLevel()->getName() == $this->getConfig()->get('aworld')) {
                             $playersleft = $this->getConfig()->get('neededplayers') - $this->aplayers;
                             $sender->sendMessage("Players left untill the game begin: " . $playersleft);
                             return true;
                         } else {
                             $sender->sendMessage("You are not in a SkyWars world.");
                             return true;
                         }
                     } else {
                         $sender->sendMessage("You haven't the permission to run this command.");
                         return true;
                     }
                     break;
                 case "see":
                     if ($sender->hasPermission("skywars.command.see") or $sender->hasPermission("skywars.command") or $sender->hasPermission("skywars")) {
                         $sender->sendMessage("You will join a match as a spectator");
                         $sender->setGamemode(3);
                         //Actually, this will crash mcpe I think.
                         $spawn = $this->getConfig()->get('spectatorspawn');
                         $sender->teleport(new Position($spawn[0], $spawn[1], $spawn[2], $this->getServer()->getLevelByName($this->getConfig()->get('aworld'))));
                     } else {
                         $sender->sendMessage("You haven't the permission to run this command.");
                         return true;
                     }
                     break;
                 default:
                     return false;
             }
     }
 }
开发者ID:EmreTr1,项目名称:SkyWarsForPE,代码行数:101,代码来源:Main.php

示例3: onCommand

 public function onCommand(CommandSender $sender, Command $cmd, $label, array $args)
 {
     $name = $sender->getName();
     switch ($cmd->getName()) {
         case "vote":
             if (!isset($args[0])) {
                 $sender->sendMessage(MT::RED . 'Vote with /vote *arenanumber* (1-5)');
                 $this->getLogger()->info("{$name} benutzt vote befehl");
                 return true;
             } else {
                 if ($args[0] == 1 || $args[0] == 2 || $args[0] == 3 || $args[0] == 4 || $args[0] == 5) {
                     $sender->sendMessage(MT::RED . 'Thank u for voting the arena ' . MT::GREEN . $args[0]);
                     $this->getLogger()->info("{$name} hat gevotet Arena {$args['0']}");
                     if ($args[0] == 1) {
                         $this->arena1[$name] = 1;
                     }
                     if ($args[0] == 2) {
                         $this->arena2[$name] = 1;
                     }
                     if ($args[0] == 3) {
                         $this->arena3[$name] = 1;
                     }
                     if ($args[0] == 4) {
                         $this->arena4[$name] = 1;
                     }
                     if ($args[0] == 5) {
                         $this->arena5[$name] = 1;
                     }
                     return true;
                 } else {
                     $sender->sendMessage(MT::RED . 'Wrong arena number or arena not loaded');
                     return false;
                 }
             }
             break;
         case "watch":
             $level = $sender->getLevel()->getName();
             if ($level == $this->lobbyname) {
                 if (isset($this->selectarena)) {
                     $arenaname = $this->selectarena;
                     if ($this->arena1name == $arenaname) {
                         $pos111 = explode(",", $this->arena1areapos1);
                         $pos222 = explode(",", $this->arena1areapos2);
                     }
                     if ($this->arena2name == $arenaname) {
                         $pos111 = explode(",", $this->arena2areapos1);
                         $pos222 = explode(",", $this->arena2areapos2);
                     }
                     if ($this->arena3name == $arenaname) {
                         $pos111 = explode(",", $this->arena3areapos1);
                         $pos222 = explode(",", $this->arena3areapos2);
                     }
                     if ($this->arena4name == $arenaname) {
                         $pos111 = explode(",", $this->arena4areapos1);
                         $pos222 = explode(",", $this->arena4areapos2);
                     }
                     if ($this->arena5name == $arenaname) {
                         $pos111 = explode(",", $this->arena5areapos1);
                         $pos222 = explode(",", $this->arena5areapos2);
                     }
                     $randx = rand($pos111[0], $pos222[0]);
                     $randz = rand($pos111[2], $pos222[2]);
                     $randy = rand($pos111[1], $pos222[1]);
                     $sender->teleport($this->getServer()->getLevelByName($this->selectarena)->getSafeSpawn(new Position($randx, $randy, $randz)));
                     $sender->setGamemode(3);
                     return true;
                 } else {
                     $sender->sendMessage(MT::RED . 'Round isnt started yet!');
                     return false;
                 }
             } else {
                 $name = $sender->getName();
                 if (in_array($name, $this->players)) {
                     $sender->sendMessage(MT::RED . 'Your are not in Lobby and playing!');
                 } else {
                     $sender->teleport($this->getServer()->getLevelByName($this->lobbyname)->getSafeSpawn());
                     $sender->setGamemode(0);
                 }
                 return false;
             }
             break;
         case "playerspawn":
             $level = $sender->getLevel()->getName();
             if ($sender->isOp()) {
                 if (isset($args[0])) {
                     $config = $this->config->getAll();
                     $ppos = $config["PlayerspawnPos"];
                     $ppos2 = $config["PlayerspawnPos2"];
                     $ppos3 = $config["PlayerspawnPos3"];
                     $ppos4 = $config["PlayerspawnPos4"];
                     $ppos5 = $config["PlayerspawnPos5"];
                     if ($args[0] == "add") {
                         if (isset($args[1])) {
                             if ($this->arena1name == $level) {
                                 $commandpos = $args[1];
                                 if (!in_array($commandpos, $ppos)) {
                                     if (!is_array($ppos)) {
                                         $ppos = array($commandpos);
                                         return true;
                                     } else {
//.........这里部分代码省略.........
开发者ID:100henrik100,项目名称:Minecraft-Pocket-Edition,代码行数:101,代码来源:minigame.php


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