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


PHP Command::getname方法代碼示例

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


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

示例1: onCommand

 public function onCommand(CommandSender $sender, Command $command, $label, array $args)
 {
     switch ($command->getname()) {
         case "sg":
             $map1status = "nr";
             $map2status = "nr";
             $map3status = "nr";
             $map4status = "nr";
             $map5status = "nr";
             $map1 = $this->getConfig()->get("name1");
             $map2 = $this->getConfig()->get("name2");
             $map3 = $this->getConfig()->get("name3");
             $map4 = $this->getConfig()->get("name4");
             $map5 = $this->getConfig()->get("name5");
             $a = array("getstatus" => $map1status);
             $b = array("getstatus" => $map2status);
             $c = array("getstatus" => $map3status);
             $d = array("getstatus" => $map4status);
             $e = array("getstatus" => $map5status);
             if (!isset($args[0])) {
                 // when client just performs /sg
                 $sender->sendMessage("[" . TEXTFORMAT::RED . "SGLite" . TEXTFORMAT::WHITE . "]" . " Please enter into a match " . "using /sg join.");
                 return true;
             }
             if ($args[0] === "join") {
                 // when client performs /sg join <match>
                 //defines all global array so that later functions can access array.
                 global $a;
                 global $b;
                 global $c;
                 global $d;
                 global $e;
                 if (!isset($args[1])) {
                     $sender->sendMessage("[" . TEXTFORMAT::RED . "SGLite" . TEXTFORMAT::WHITE . "]" . " /sg join " . $map1);
                     $sender->sendMessage("[" . TEXTFORMAT::RED . "SGLite" . TEXTFORMAT::WHITE . "]" . " /sg join " . $map2);
                     $sender->sendMessage("[" . TEXTFORMAT::RED . "SGLite" . TEXTFORMAT::WHITE . "]" . " /sg join " . $map3);
                     $sender->sendMessage("[" . TEXTFORMAT::RED . "SGLite" . TEXTFORMAT::WHITE . "]" . " /sg join " . $map4);
                     $sender->sendMessage("[" . TEXTFORMAT::RED . "SGLite" . TEXTFORMAT::WHITE . "]" . " /sg join " . $map5);
                     return true;
                 }
                 if ($args[1] === $map1) {
                     $player = $sender->getName();
                     //sends all variable information into the datafolder.
                     $sender->sendMessage("[" . TEXTFORMAT::RED . "SGLite" . TEXTFORMAT::WHITE . "]" . " Transporting to map " . $map1);
                     //sets player into map list.
                     \array_push($a, $player);
                     if (Server::getInstance()->loadLevel($map1) != false) {
                         $sender->getPlayer()->teleport(Server::getInstance()->getLevelByName($map1)->getSafeSpawn());
                         $sender->sendMessage("[" . TEXTFORMAT::RED . "SGLite" . TEXTFORMAT::WHITE . "]" . " Please enter command /match1 register" . " to register into the match.");
                         include $this->getDataFolder() . "/" . "/required/" . "match1.php";
                         $str = fopen("match1pro.txt", "w");
                         $message = "nr";
                         \fwrite($str, $message);
                         foreach ($a as $player) {
                             $player = $this->getServer()->getPlayer($player);
                             $mapname = $this->getConfig()->get("name1");
                             if ($sender instanceof Player) {
                                 $sender->sendMessage("Map 1 - '" . TEXTFORMAT::BLUE . $mapname . TEXTFORMAT::WHITE . "'");
                             }
                         }
                         return true;
                     } else {
                         //map doesn't exist, so tells the player there's an error.
                         $sender->sendMessage("[" . TEXTFORMAT::RED . "SGLite" . TEXTFORMAT::WHITE . "]" . "This" . " match is non-existant. Please check for errors.");
                     }
                     if ($args[1] === "map2") {
                         //gets player name and returns as $player
                         $player = $sender->getName();
                         //send player confirmation.
                         $player->sendMessage("[" . TEXTFORMAT::RED . "SGLite" . TEXTFORMAT::WHITE . "]" . " Transport to map " . $map2);
                         //sets player into map list.
                         array_push($b, $player);
                         if (Server::getInstance()->loadLevel($map2) != false) {
                             $event->getPlayer()->teleport(Server::getInstance()->getLevelByName($map2)->getSafeSpawn());
                             return true;
                         } else {
                             $player->sendMessage("[" . TEXTFORMAT::RED . "SGLite" . TEXTFORMAT::WHITE . "]" . " That map is currently unavailable.");
                             return true;
                         }
                     }
                     if ($args[1] === "map3") {
                         //gets player name and returns as $player
                         $player = $sender->getName();
                         //send player confirmation.
                         $player->sendMessage("[" . TEXTFORMAT::RED . "SGLite" . TEXTFORMAT::WHITE . "]" . " Transport to map " . $map3);
                         //sets player into map list.
                         array_push($c, $player);
                         if (Server::getInstance()->loadLevel($map3) != false) {
                             $event->getPlayer()->teleport(Server::getInstance()->getLevelByName($map3)->getSafeSpawn());
                             return true;
                         } else {
                             $player->sendMessage("[" . TEXTFORMAT::RED . "SGLite" . TEXTFORMAT::WHITE . "]" . " That map is currently unavailable.");
                             return true;
                         }
                     }
                     if ($args[1] === "map4") {
                         //gets player name and returns as $player
                         $player = $sender->getName();
                         //send player confirmation.
                         $player->sendMessage("[" . TEXTFORMAT::RED . "SGLite" . TEXTFORMAT::WHITE . "]" . " Transport to map " . $map4);
//.........這裏部分代碼省略.........
開發者ID:Edwardthedog2,項目名稱:SGLite,代碼行數:101,代碼來源:SGPro.php


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