本文整理汇总了PHP中pocketmine\command\CommandSender::teleport方法的典型用法代码示例。如果您正苦于以下问题:PHP CommandSender::teleport方法的具体用法?PHP CommandSender::teleport怎么用?PHP CommandSender::teleport使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pocketmine\command\CommandSender
的用法示例。
在下文中一共展示了CommandSender::teleport方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: onCommand
public function onCommand(CommandSender $sender, Command $command, $label, array $args)
{
if ($player->hasPermission("signstats.commands.stats")) {
switch ($command->getName()) {
case 'sethouse':
$this->config->player[$sender->getName()]['house']['x'] = $sender->x;
$this->config->player[$sender->getName()]['house']['y'] = $sender->y;
$this->config->player[$sender->getName()]['house']['z'] = $sender->z;
$sender->sendMessage(TextFormat::GREEN . '[EasyHouse] House set.');
break;
case 'delhouse':
unset($this->config->player[$sender->getName()]['house']);
$sender->sendMessage(TextFormat::RED . '[EasyHouse] house Deleted');
break;
case 'house':
if (isset($this->config->player[$sender->getName()]['house'])) {
$this->viellePosition[$sender->getName()] = array($sender->x, $sender->y, $sender->z);
$sender->teleport(new Vector3($this->config->player[$sender->getName()]['house']['x'], $this->config->player[$sender->getName()]['house']['y'], $this->config->player[$sender->getName()]['house']['z']));
$sender->sendMessage(TextFormat::GREEN . '[EasyHouse] Teleported.');
} else {
$sender->sendMessage(TextFormat::RED . 'House is not set.');
}
break;
}
} else {
$player->sendMessage(TextFormat::RED . "[EasyHouse] You don't have permissions!");
}
}
示例2: onCommand
public function onCommand(CommandSender $sender, Command $command, $label, array $args)
{
if ($sender instanceof Player) {
if (count($args) == 0) {
$sender->sendMessage(TextFormat::RED . "Not enough arguments.");
return;
}
if (count($args) == 1) {
if ($this->getServer()->getPlayer($args[0])) {
$location = $this->getServer()->getPlayer($args[0])->getLocation();
$sender->teleport($location);
$sender->sendMessage(TextFormat::BLUE . "[Server] You have teleported to {$args['0']}");
return;
} else {
$sender->sendMessage(TextFormat::RED . "[Server] That player isn't online!");
return;
}
}
if (count($args) == 2) {
if ($this->getServer()->getPlayer($args[0]) & getLocation() && $this->getServer()->getPlayer($args[1])) {
$location2 = $this->getServer()->getPlayer($args[1])->getLocation();
$player1 = $this->getServer()->getPlayer($args[0]);
$player2 = $this->getServer()->getPlayer($args[1]);
$player1->teleport($location2);
$player1->sendMessage(TextFormat::BLUE . "[Server] You have teleported to {$args['1']}");
return;
}
}
}
}
示例3: onCommand
public function onCommand(CommandSender $sender, Command $cmd, $label, array $sub)
{
$mm = "[TeleportView] ";
if ($sender->getName() == "CONSOLE") {
$sender->sendMessage($mm . ($this->isKorean() ? "게임내에서만 사용가능합니다." : "Please run this command in-game"));
return true;
}
$yaw = $sender->getYaw();
$ptch = $sender->getPitch();
$yawS = -sin($yaw / 180 * M_PI);
$yawC = cos($yaw / 180 * M_PI);
$ptchS = -sin($ptch / 180 * M_PI);
$ptchC = cos($ptch / 180 * M_PI);
$x = $sender->getX();
$y = $sender->getY() + $sender->getEyeHeight();
$z = $sender->getZ();
$l = $sender->getLevel();
for ($f = 0; $f < 50; ++$f) {
$x += $yawS * $ptchC;
$y += $ptchS;
$z += $yawC * $ptchC;
$b = $l->getBlock(new Position($x, $y, $z, $l));
if ($b->isSolid) {
$sender->teleport(new Position($x - $yawS * $ptchC, $y - $ptchS + 0.1, $z - $yawC * $ptchC, $l));
$f = true;
}
}
if (!isset($f)) {
$sender->sendMessage($mm . ($this->isKorean() ? "타겟 블럭이 너무 멉니다." : "TargetBlock is too far"));
}
return true;
}
示例4: onCommand
public function onCommand(CommandSender $sender, Command $cmd, $label, array $sub)
{
$mm = "[TeleportView] ";
if ($sender->getName() == "CONSOLE") {
$sender->sendMessage($mm . ($this->isKorean() ? "게임내에서만 사용가능합니다." : "Please run this command in-game"));
return true;
}
$yaw = $sender->getYaw();
$pitch = $sender->getPitch();
$yawS = -sin($yaw / 180 * M_PI);
$yawC = cos($yaw / 180 * M_PI);
$pitchS = -sin($pitch / 180 * M_PI);
$pitchC = cos($pitch / 180 * M_PI);
$x = $sender->x;
$y = $sender->y + $sender->getEyeHeight();
$z = $sender->z;
$l = $sender->getLevel();
$ps = $this->getServer()->getOnlinePlayers();
for ($f = 0; $f < 50; ++$f) {
$x += $yawS * $pitchC;
$y += $pitchS;
$z += $yawC * $pitchC;
$b = $l->getBlock(new Position($x, $y, $z, $l));
if ($b->isSolid()) {
break;
}
if ($f >= 50) {
$sender->sendMessage($mm . ($this->isKorean() ? "타겟 블럭이 너무 멉니다." : "TargetBlock is too far"));
return true;
}
}
$sender->teleport(new Position($x, $y, $z, $sender->getLevel()));
return true;
}
示例5: onCommand
public function onCommand(CommandSender $sender, Command $command, $label, array $args)
{
if (!$sender instanceof Player) {
$sender->sendMessage("This command must be used in-game.");
return true;
}
switch (strtolower($command->getName())) {
case "shop":
$sender->teleport(new Location(-280.279358, 66.00000300000001, 368.750275, 179, -1, $this->getServer()->getLevelByName("Gorzen")));
break;
case "pvp":
$sender->teleport(new Location(1701.638306, 12.663271, -1027.24585, 179, -1, $this->getServer()->getLevelByName("PvP")));
break;
default:
$sender->sendMessage("Invalid command.");
break;
}
return true;
}
示例6: onCommand
public function onCommand(CommandSender $sender, Command $command, $label, array $args)
{
if (strtolower($command->getName()) === "spawnport") {
if (!$sender instanceof Player) {
$sender->sendMessage(TextFormat::AQUA . "Please run this command in game");
return true;
}
$worldspawn = $sender->getLevel()->getSpawnLocation();
$sender->teleport($worldspawn);
$sender->sendMessage(TextFormat::AQUA . "Teleported to WorldSpawn");
}
return true;
}
示例7: onCommand
public function onCommand(CommandSender $sender, Command $cmd, $label, array $args)
{
if (strtolower($cmd->getName()) === "spawn" && $this->main->getConfig()->get("Spawn-Command-Enabled") === true) {
if ($sender instanceof Player) {
if ($sender->hasPermission("morecommands.command.spawn")) {
$sender->sendMessage($this->main->getConfig()->get("Teleport-to-Spawn-Message"));
$sender->teleport($this->main->getServer()->getDefaultLevel()->getSpawnLocation());
return true;
} else {
$sender->sendMessage(TextFormat::RED . "You don't have permissions to use this command.");
}
} else {
$sender->sendMessage(TextFormat::RED . "Please use this command in-game!");
return true;
}
}
}
示例8: onCommand
public function onCommand(CommandSender $player, Command $cmd, $label, array $args)
{
switch ($cmd->getName()) {
case "bw":
if ($player->isOp()) {
if ($this->mode == 0 and $args[0] == "addarena") {
$this->mode = 1;
$player->sendMessage(TextFormat::YELLOW . "Use /bw add [worldname] to add an arena");
} elseif ($this->mode == 1 and $args[0] == "add") {
if (file_exists($this->getServer()->getDataPath() . "/worlds/" . $args[0])) {
if (!$this->getServer()->getLevelByName($args[1]) instanceof Level) {
$this->getServer()->loadLevel($args[1]);
}
$spawn = $this->getServer()->getLevelByName($args[1])->getSafeSpawn();
$this->getServer()->getLevelByName($args[1])->loadChunk($spawn->x, $spawn->z);
if ($player instanceof Player) {
$player->teleport($spawn);
}
$this->arenaname = $args[1];
$player->sendMessage(TextFormat::GREEN . "You have successfully entered the arena! Now you have to set 4 bases");
$player->sendMessage(TextFormat::GOLD . "Touch" . TextFormat::BLUE . "Team blue" . TextFormat::GOLD . "'s bed now");
$this->mode = 2;
} else {
$player->sendMessage(TextFormat::RED . "This is not a valid name!");
}
} elseif ($this->mode == 0 and $args[0] == "regsign" and isset($args[1])) {
if (file_exists($this->getDataFolder() . "/arenas/" . $args[1])) {
$player->sendMessage(TextFormat::YELLOW . "You are about to register a sign for the arena {$args['1']}. Tap a sign to activate it!");
$this->regname = $args[1];
$this->mode = 10;
} else {
$player->sendMessage(TextFormat::RED . "This is not a valid name!");
}
} elseif ($this->mode == 0 and $args[0] == "regsign") {
$player->sendMessage(TextFormat::YELLOW . "Usage: /bw regsign [worldname]");
} elseif ($args[0] == "cancel") {
$this->mode = 0;
$player->sendMessage(TextFormat::GREEN . "Cancelled!");
}
}
return true;
}
return true;
}
示例9: 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;
}
示例10: onCommand
public function onCommand(CommandSender $sender, Command $cmd, $label, array $args)
{
switch ($cmd->getName()) {
case "skywarshowto":
if ($sender->hasPermission("skywars.command.howto") or $sender->hasPermission("skywars.command") or $sender->hasPermission("skywars")) {
$sender->sendMessage("----How To Play skywars----");
$sender->sendMessage("/sk play = start a game");
$sender->sendMessage("/sk exit = exit from a game");
$sender->sendMessage("/sk stat [player] = get a player stats");
$sender->sendMessage("/sk skiptime = skip the waiting time");
return true;
} else {
$sender->sendMessage("You haven't the permission to run this command");
}
case "skywars":
case "sw":
//same as setting aliases in plugin.yml, both cmds (skywars & sw) are usable
//same as setting aliases in plugin.yml, both cmds (skywars & sw) are usable
case "sk":
switch ($args[0]) {
case "play":
if ($sender->hasPermission("skywars.command.play") or $sender->hasPermission("skywars.command") or $sender->hasPermission("skywars")) {
if ($this->aplayers >= $this->getConfig()->get('neededplayers') and $this->skywarsstarted == false) {
//if players in the world are more or equal as the max players
$sender->sendMessage("The game is full");
// game full
return true;
} elseif ($this->aplayers < $this->getConfig()->get('neededplayers') and $this->skywarsstarted == false) {
//if player number is less than the max.
$spawn = $this->getConfig()->get('spawns')[$this->aplayers];
//no need to do + 1 on this, because arrays start counting form 0 // get the correct spawn place
$sender->teleport(new Position($spawn[0], $spawn[1], $spawn[2], $this->getServer()->getLevelByName($this->getConfig()->get('aworld'))));
//teleport to it
$this->aplayers = $this->aplayers + 1;
//then add a player to the array
$sender->sendMessage("You have been teleported to the game world.");
if ($this->aplayers == $this->getConfig()->get('neededplayers')) {
//if the players became the same as neededplayers
$this->startGame($this->getConfig() > get('aworld'));
//start the game
}
return true;
} elseif ($this->skywarsstarted == true) {
//if the game is already started
$sender->sendMessage("The game is already started");
return true;
}
} else {
$sender->sendMessage("You haven't the permission to run this command.");
return true;
}
break;
case "exit":
if ($sender->hasPermission("skywars.command.exit") or $sender->hasPermission("skywars.command") or $sender->hasPermission("skywars")) {
if ($sender->getLevel()->getName() == $this->getConfig()->get('aworld')) {
//if the level of the sender is a skywars one
$this->aplayers = $this->aplayers - 1;
//remove 1 to the array
$sender->teleport($this->getServer()->getLevelByName($this->getConfig() > get('lobby'))->getSafeSpawn());
//teleport to the lobby
$sender->sendMessage("You left the game.");
if ($this->aplayers <= 1) {
//if only 1 player is left
foreach ($this->getServer()->getLevelByName($this->getConfig()->get('aworld'))->getPlayers() as $p) {
//detects the winner
if ($p->getGameMode() == 0) {
$p->sendMessage("You won the match!");
$p->sendMessage("The game has finished, you will be teleported to the lobby.");
$p->teleport($this->getServer()->getLevelByName($this->config->get('lobby'))->getSafeSpawn());
//teleport to the lobby
$points = $this->points->get($p)[2] + $this->getConfig()->get('points-per-match');
//get points and add
$deaths = $this->points->get($player)[0];
//get the victim's deaths, add one and store in a variable
$kills = $this->points->get($player)[1];
//get the players kills and store in a var
$this->getConfig()->set($p, array($deaths, $kills, $points));
} else {
$p->sendMessage("The match has finished, thanks for watching.");
$p->teleport($this->getServer()->getLevelByName($this->getConfig()->get('lobby'))->getSafeSpawn());
$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();
//.........这里部分代码省略.........
示例11: onCommand
public function onCommand(CommandSender $sender, Command $command, $label, array $args)
{
$this->getLogger()->info("test");
if ($command->getName() == "pk") {
if ($args[0] == "join") {
if (isset($args[1])) {
if (isset($this->arenas[strtolower($args[1])]) and substr(strtolower($args[1]), -5) != "_race") {
if (!isset($this->activeplayers[$sender->getName()])) {
$this->activeplayers[$sender->getName()] = array("current-map" => strtolower($args[1]), "last-set" => 0, "micro-seconds" => 0, "active" => false, "current-checkpoint" => 0);
$sender->teleport($this->arenas[strtolower($args[1])]->getStartPosition());
$sender->setRotation($this->arenas[strtolower($args[1])]->getStartYaw(), $sender->getPitch());
$sender->sendMessage("§cYou have started the map '§b" . $this->arenas[strtolower($args[1])]->getMapName() . "§c'.");
} else {
$sender->sendMessage("§cYou are currently still playing a different map\n§cUse §b/pk leave§c to leave this map.");
}
} else {
$sender->sendMessage("§cThe map '§b" . strtolower($args[1]) . "§c' doesn't exist.");
}
} else {
$sender->sendMessage("§cUsage: §b/pk join [map name]");
}
} else {
if ($args[0] == "leave") {
if (isset($this->activeplayers[$sender->getName()])) {
unset($this->activeplayers[$sender->getName()]);
$sender->sendMessage("§cYou have left your current map.");
} else {
$sender->sendMessage("§cYou aren't currently playing any maps.");
}
} else {
if ($args[0] == "info") {
if (isset($args[1])) {
if (isset($this->arenas[strtolower($args[1])])) {
$map = $this->arenas[strtolower($args[1])];
$currentlyplaying = array();
foreach ($this->activeplayers as $player => $name) {
if ($name['current-map'] == strtolower($args[1])) {
array_push($currentlyplaying, $player);
}
}
$sender->sendMessage("§cMap info:\n§cMap name: §b" . $map->getMapName() . "\n§cMap maker: §b" . $map->getMapMaker() . "\n§cDate of creation: §b" . $map->getDateOfCreation() . "\n§cMap world name: §b" . $map->getMapLevel()->getName() . "\n§cYour current highscore: §b" . ($map->getTime($sender) === null ? "none" : $map->getTime($sender)) . "\n§cCurrently playing: §b" . implode(", ", $currentlyplaying) . "\n§cFor leaderboards, please type §b/pk topten " . strtolower($args[1]));
} else {
$sender->sendMessage("§cThis map doesn't exist.");
}
} else {
$sender->sendMessage("§cUsage: §b/pk info [map name]");
}
} else {
if ($args[0] == "topten") {
if (isset($args[1])) {
if (isset($this->arenas[strtolower($args[1])])) {
$sender->sendMessage("§cTop ten laps of the map §b" . $this->arenas[strtolower($args[1])]->getMapName() . "§c:");
$count = 0;
foreach ($this->arenas[strtolower($args[1])]->getTopTen() as $player) {
$count++;
$sender->sendMessage("§c" . $count . ") §b" . $player['username'] . "§c with §b" . $player['highscore']);
}
} else {
$sender->sendMessage("§cThis map doesn't exist.");
}
} else {
$sender->sendMessage("§cUsage: §b/pk topten [map name]");
}
}
}
}
}
if ($args[0] == "create") {
if (isset($args[1])) {
$this->arenaconf->set($args[1], array("date-of-creation" => date("d/m/Y"), "map-maker" => $sender->getName(), "level" => $sender->getLevel()->getName(), "floor-y" => 0, "start-position" => array("x" => 0, "y" => 0, "z" => 0, "yaw" => 360), "timer-block" => array("x" => 0, "y" => 0, "z" => 0), "end-block" => array("x" => 0, "y" => 0, "z" => 0)));
$sender->sendMessage("§cNew map '§b" . $args[1] . "§c' has been created.\n§cPlease use the follwing command to set the start position:\n§b/pk setstart " . strtolower($args[1]));
} else {
$sender->sendMessage("§cUsage: §b/pk create [map name]");
}
} else {
if ($args[0] == "setstart") {
if (isset($args[1])) {
if ($this->arenaconf->exists($args[1])) {
$newmap = $this->arenaconf->get($args[1]);
$newmap['start-position'] = array("x" => $sender->getFloorX(), "y" => $sender->getFloorY(), "z" => $sender->getFloorZ(), $sender->getYaw());
$this->arenaconf->set($args[1], $newmap);
$sender->sendMessage("§cAwesome! Now use the follwing command to set the floor that will reset you once you fall below/on it.\n§b/pk setfloor " . strtolower($args[1]));
} else {
$sender->sendMessage("§cThis map doesn't exist.");
}
} else {
$sender->sendMessage("§cUsage: §b/pk setfloor [map name]");
}
} else {
if ($args[0] == "setfloor") {
if (isset($args[1])) {
if ($this->arenaconf->exists($args[1])) {
$newmap = $this->arenaconf->get($args[1]);
$newmap['floor-y'] = $sender->getFloorY();
$this->arenaconf->set($args[1], $newmap);
$sender->sendMessage("§cGreat! Now use the follwing command to set the timer start position.\n§b/pk settimer " . strtolower($args[1]));
} else {
$sender->sendMessage("§cThis map doesn't exist.");
}
} else {
//.........这里部分代码省略.........
示例12: onCommand
public function onCommand(CommandSender $sender, Command $command, $label, array $args)
{
if ($command->getName() == "lobby") {
if ($this->gameStatus >= 2) {
$sender->sendMessage("[{$this->getConfig()->get("prefix")}] {$Already_Playing}");
return;
}
if (isset($this->players[$sender->getName()])) {
unset($this->players[$sender->getName()]);
$sender->setLevel($this->signlevel);
$sender->teleport($this->signlevel->getSpawnLocation());
$sender->sendMessage(TextFormat::GREEN . "[{$this->getConfig()->get("prefix")}] Teleporting to lobby...");
$this->getServer()->broadcastMessage(TextFormat::RED . "[{$this->getConfig()->get("prefix")}]Player " . $sender->getName() . " left the match.");
$this->changeStatusSign();
if ($this->gameStatus == 1 && count($this->players) < 2) {
$this->gameStatus = 0;
$this->lastTime = 0;
$event->getPlayer()->sendMessage("[{$this->getConfig()->get("prefix")}] {$Arena}");
/*foreach($this->players as $pl)
{
$p=$this->getServer()->getPlayer($pl["id"]);
$p->setLevel($this->signlevel);
$p->teleport($this->signlevel->getSpawnLocation());
unset($p,$pl);
}*/
}
} else {
$sender->sendMessage(TextFormat::RED . "[{$this->getConfig()->get("prefix")}] {$Not_In_Match}");
}
return true;
}
if (!isset($args[0])) {
unset($sender, $cmd, $label, $args);
return false;
}
switch ($args[0]) {
case "help":
if ($sender->hasPermission("sg.command.help") or $sender->hasPermission("sg.command") or $sender->hasPermission("sg")) {
$sender->sendMessage("§d§o-------SurvivalGames Help-------");
$sender->sendMessage("§d§oUse §e/sg stats - View your stats");
$sender->sendMessage("§d§oUse §e/sg set - Set up an arena");
$sender->sendMessage("§d§oUse §e/sg remove - Remove a arena");
$sender->sendMessage("§d§oUse §e/sg start - Force start a match");
$sender->sendMessage("§d§oUse §e/sg reload - Reload the spawn positions");
$sender->sendMessage("§d§o--------------------------------");
return true;
}
break;
case "stats":
if ($sender instanceof Player) {
if ($sender->hasPermission("sg.command.stats") or $sender->hasPermission("sg.command") or $sender->hasPermission("sg")) {
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(TextFormat::RED . "[{$this->getConfig()->get("prefix")}] ---------------");
$sender->sendMessage(TextFormat::RED . "[{$this->getConfig()->get("prefix")}] §bYou're stats");
$sender->sendMessage(TextFormat::RED . "[{$this->getConfig()->get("prefix")}] §lDeaths: §9{$deaths}");
$sender->sendMessage(TextFormat::RED . "[{$this->getConfig()->get("prefix")}] §lKills: §9{$kills}");
$sender->sendMessage(TextFormat::RED . "[{$this->getConfig()->get("prefix")}] ---------------");
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(TextFormat::RED . "[{$this->getConfig()->get("prefix")}] ---------------");
$sender->sendMessage(TextFormat::RED . "[{$this->getConfig()->get("prefix")}] §bPlayer: §9{$player} Stats");
$sender->sendMessage(TextFormat::RED . "[{$this->getConfig()->get("prefix")}] §lDeaths: §9{$deaths}");
$sender->sendMessage(TextFormat::RED . "[{$this->getConfig()->get("prefix")}] §lKills: §9{$kills}");
$sender->sendMessage(TextFormat::RED . "[{$this->getConfig()->get("prefix")}] ---------------");
return true;
}
} else {
$sender->sendMessage("{$No_Permission}");
return true;
}
} else {
$sender->sendMessage(TextFormat::RED . "That command can only be used in-game!");
return true;
}
break;
case "set":
if ($sender instanceof Player) {
if ($this->config->exists("lastpos")) {
$sender->sendMessage("Seems like you have already setup an arena");
} else {
$name = $sender->getName();
$this->SetStatus[$name] = 0;
$sender->sendMessage("Tap a sign to set it as join sign!");
}
} else {
$sender->sendMessage(TextFormat::RED . "You may only use ths command in-game!");
return true;
}
break;
case "remove":
$this->config->remove("sign");
$this->config->remove("pos1");
//.........这里部分代码省略.........
示例13: onCommand
public function onCommand(CommandSender $runner, Command $call, $alia, array $arg)
{
switch (strtolower($call->getName())) {
case 'brawl':
if (empty($arg) && $runner instanceof Player) {
$runner->sendMessage(TextFormat::RED . "Usage: /brawl <join|quit>");
}
if ($runner->hasPermission("brawl.cmd") && $runner instanceof Player && isset($arg[0])) {
switch (strtolower($arg[0])) {
case 'join':
if (!isset($this->brawl[$runner->getName()])) {
$this->cnt[$runner->getName()] = 0;
$this->brawl[$runner->getName()] = $runner;
$runner->teleport(new Position($this->wx, $this->wy, $this->wz, $this->wlvl), 0, 0);
foreach ($this->brawl as $pl) {
$pl->sendMessage(TextFormat::GOLD . "[CL-BrawlArena] " . $runner->getName() . " joined the match.");
}
if (count($this->brawl) >= $this->min) {
$t = new WaitTask($this);
$h = $this->getServer()->getScheduler()->scheduleDelayedTask($t, 20 * $this->wait_time);
$t->setHandler($h);
foreach ($this->brawl as $pl) {
$min = $this->wait_time / 60;
$pl->sendMessage(TextFormat::GOLD . "[CL-BrawlArena] Game starting in " . ($this->wait_time <= 60 ? "{$this->wait_time} seconds" : "{$min} minutes."));
break;
}
}
} else {
$runner->sendMessage(TextFormat::RED . "[CL-BrawlArena] You already joined.");
}
if (count($this->brawl) >= $this->max) {
$runner->sendMessage(TextFormat::RED . "[CL-BrawlArena] Game full.");
}
if ($this->running) {
$runner->sendMessage(TextFormat::RED . "[CL-BrawlArena] Game already running.");
}
break;
case 'quit':
if (isset($this->brawl[$runner->getName()])) {
$runner->teleport(new Position($this->lx, $this->ly, $this->lz, $this->llvl), 0, 0);
$runner->sendMessage(TextFormat::GREEN . "[CL-BrawlArena] Teleporting...");
unset($this->brawl[$runner->getName()]);
unset($this->cnt[$runner->getName()]);
if (count($this->brawl) <= 0) {
$this->getServer()->broadcastMessage(TextFormat::GREEN . "[CL-BrawlArena] Game is open.");
$this->running = false;
unset($this->brawl);
unset($this->cnt);
}
}
break;
}
}
break;
}
}
示例14: 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 {
//.........这里部分代码省略.........
示例15: tpCommand
function tpCommand(CommandSender $sender, array $args)
{
if (count($args) !== 0) {
$sender->sendMessage($this->getMessage("l.tp.usage"));
return true;
}
if (($pair = $this->provider->getPair($sender->getName())) === null) {
$sender->sendMessage($this->getMessage("l.no-married"));
return true;
}
if (!($Player = $this->getServer()->getPlayer($pair))) {
$sender->sendMessage($this->getMessage("l.pair-offline"));
return true;
}
$sender->teleport($Player);
return true;
}