本文整理汇总了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);
//.........这里部分代码省略.........