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


PHP CommandSender::getPosition方法代码示例

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


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

示例1: execute

 public function execute(CommandSender $sender, array $args)
 {
     if (!empty($args)) {
         return false;
     }
     $player = $sender->getServer()->getPlayer($sender->getName());
     $levelName = $player->getLevel()->getName();
     if (!$this->getPlugin()->isLevelLoaded($levelName)) {
         $sender->sendMessage(TextFormat::RED . "You are not inside a plot world");
         return true;
     }
     $sender->sendMessage(TextFormat::RED . "Finding a free plot for you");
     if ($this->getPlugin()->getProvider() instanceof \MyPlot\provider\MYSQLDataProvider) {
         $plot = $this->getPlugin()->getPlotByPosition($sender->getPosition());
         $plot = $this->getPlugin()->getProvider()->getNextFreePlot($levelName, 20, $plot->X, $plot->Z);
     } else {
         $plot = $this->getPlugin()->getProvider()->getNextFreePlot($levelName);
     }
     if ($plot !== null) {
         $this->getPlugin()->teleportPlayerToPlot($player, $plot);
         $sender->sendMessage(TextFormat::GREEN . "Teleported to " . TextFormat::WHITE . $plot);
         $sender->sendMessage(TextFormat::GREEN . "If you dont like this plot use the /p auto command again to find another.");
     } else {
         $sender->sendMessage(TextFormat::RED . "No free plots found in this world");
     }
     return true;
 }
开发者ID:mwvent,项目名称:WattzMCPE-MyPlot,代码行数:27,代码来源:AutoSubCommand.php

示例2: execute

 public function execute(CommandSender $sender, $label, array $params)
 {
     if (!$this->plugin->isEnabled()) {
         return false;
     }
     if (!$sender instanceof Player) {
         $sender->sendMessage("Please use the command in-game");
         return true;
     }
     if ($sender->hasPermission("hungergames.addlobby")) {
         $this->arenaManager->setLobbySpawn($sender->getPosition());
         return true;
     }
 }
开发者ID:TuffDev,项目名称:HungerGames,代码行数:14,代码来源:AddLobbyCommand.php

示例3: onCommand

 public function onCommand(CommandSender $sender, Command $command, $label, array $args)
 {
     if ($sender instanceof Player) {
         switch ($command->getName()) {
             case "tpaccept":
                 if (in_array($sender->getName(), $this->requests)) {
                     foreach ($this->requests as $requester => $accepter) {
                         if ($accepter === $sender->getName()) {
                             $pos = $sender->getPosition();
                             $sender->sendMessage("§8§l[§bDark§4Realms§8§l]" . TextFormat::GREEN . "TPA request accepted!");
                             $requester = $this->getServer()->getPlayer($requester);
                             $requester->sendMessage("TPA request accepted teleporting in " . $this->config->get("tpdelay") . " secs!");
                             $task = new teleport($this, $sender, $pos);
                             $this->getServer()->getScheduler()->scheduleDelayedTask($task, 20 * $this->getConfig()->get("tpdelay"));
                             $this->removeRequest($requester);
                         }
                     }
                 } else {
                     $sender->sendMessage("No pending tpa requests :(");
                 }
                 break;
             case "tpa":
                 if (isset($args[0])) {
                     $requestp = $this->getServer()->getPlayer($args[0]);
                     if ($requestp instanceof Player) {
                         if ($this->config->get("usefriendapi") == true) {
                             if ($this->friendsapi->isFriend($sender, $requestp->getName())) {
                                 $sender->sendMessage("Sent tpa request!");
                                 $this->addRequest($sender, $requestp);
                             } else {
                                 $sender->sendMessage("You are not friends with this player. :( \nDo /friend add [name] \nto request to be friends");
                             }
                         } else {
                             $sender->sendMessage("Sent tpa request!");
                             $this->addRequest($sender, $requestp);
                         }
                     } else {
                         $sender->sendMessage("§8§l[§bDark§4Realms§8§l] Player not online :(");
                     }
                 } else {
                     $sender->sendMessage("USAGE: /tpa [name]");
                 }
                 break;
         }
     }
 }
开发者ID:xHFx,项目名称:TpaFriends,代码行数:46,代码来源:main.php

示例4: execute

 public function execute(CommandSender $sender, $label, array $params)
 {
     if (!$this->plugin->isEnabled()) {
         return false;
     }
     if (!$sender instanceof Player) {
         $sender->sendMessage("Please use the command in-game");
         return true;
     }
     if ($sender->hasPermission("hungergames.spawnadd")) {
         //Get location of issuer
         $position = $sender->getPosition();
         //Add spawnpoint where user is standing for Arena(id)
         if (isset($params[0])) {
             $this->arenaManager->addSpawnpoint($position, $sender, $params[0]);
         } else {
             $sender->sendMessage(TextFormat::DARK_BLUE . "[HungerGames]" . TextFormat::WHITE . " Include the id of the arena ");
         }
         return true;
     } else {
         $sender->sendMessage(TextFormat::RED . "[HungerGames] You do not have the permissions to use this command");
     }
 }
开发者ID:TuffDev,项目名称:HungerGames,代码行数:23,代码来源:SpawnAddCommand.php

示例5: onCommand

 public function onCommand(CommandSender $sender, Command $command, $label, array $args)
 {
     switch ($command->getName()) {
         case 'ss':
             switch ($args[0]) {
                 case 'arena':
                     switch ($args[1]) {
                         case 'create':
                             if ($sender instanceof Player) {
                                 $spawn = $sender->getPosition();
                                 $arena = $this->createArena($args[2], $spawn);
                                 if ($arena != false) {
                                     $sender->sendMessage(TextFormat::AQUA . "[SimpleSpleef] " . TextFormat::GOLD . "Created arena " . $args[2]);
                                 } else {
                                     $sender->sendMessage(TextFormat::DARK_RED . "Error while creating the arena.");
                                 }
                             }
                             return true;
                             break;
                         case 'edit':
                             switch ($args[2]) {
                                 case 'spawn':
                                     if ($sender instanceof Player) {
                                         $arena = $this->getArenaByName($args[3]);
                                         if ($arena instanceof Arena) {
                                             $arena->setSpawn($sender->getPosition());
                                             $sender->sendMessage(TextFormat::AQUA . "[SimpleSpleef] " . TextFormat::GOLD . "Set new arena spawn.");
                                         }
                                     }
                                     return true;
                                     break;
                                 case 'state':
                                     if ($sender instanceof Player) {
                                         $arena = $this->getArenaByName($args[3]);
                                         if ($arena instanceof Arena) {
                                             if ($arena->enabled == false) {
                                                 $arena->enabled = true;
                                                 $sender->sendMessage(TextFormat::AQUA . "[SimpleSpleef] " . TextFormat::GOLD . "Enabled arena.");
                                             } else {
                                                 $arena->enabled = false;
                                                 $sender->sendMessage(TextFormat::AQUA . "[SimpleSpleef] " . TextFormat::GOLD . "Disabled arena.");
                                             }
                                         }
                                     }
                                     return true;
                                     break;
                                 case 'floor':
                                     if ($sender instanceof Player) {
                                         $arena = $this->getArenaByName($args[3]);
                                         if ($arena instanceof Arena) {
                                             $arena->setFloor($sender->getPosition()->getFloorY());
                                             $sender->sendMessage(TextFormat::AQUA . "[SimpleSpleef] " . TextFormat::GOLD . "Set arena floor.");
                                         }
                                     }
                                     return true;
                                     break;
                                 case 'start':
                                     if ($sender instanceof Player) {
                                         $arena = $this->getArenaByName($args[3]);
                                         if ($arena instanceof Arena) {
                                             $arena->second = 1;
                                             $sender->sendMessage(TextFormat::AQUA . "[SimpleSpleef] " . TextFormat::GOLD . "Started arena " . $arena->getArenaName());
                                         }
                                     }
                                     break;
                                 case 'stop':
                                     if ($sender instanceof Player) {
                                         $arena = $this->getArenaByName($args[3]);
                                         if ($arena instanceof Arena) {
                                             $arena->resetArena();
                                             $sender->sendMessage(TextFormat::AQUA . "[SimpleSpleef] " . TextFormat::GOLD . "Stopped arena " . $arena->getArenaName());
                                         }
                                     }
                                     break;
                             }
                             break;
                     }
                     break;
             }
             break;
         case 'spleef':
             if ($sender instanceof Player) {
                 switch ($args[0]) {
                     case 'join':
                         $arena = $this->getArenaByName($args[1]);
                         if ($arena instanceof Arena and isset($sender->arena) == false) {
                             $arena->addPlayer($sender);
                         } else {
                             $sender->sendMessage(TextFormat::AQUA . "[SimpleSpleef] " . TextFormat::GOLD . "You're already in an arena.");
                         }
                         return true;
                         break;
                     case 'leave':
                         $arena = $sender->arena;
                         if (!isset($sender->arena)) {
                             $sender->sendMessage(TextFormat::AQUA . "[SimpleSpleef] " . TextFormat::GOLD . "You're not in an arena.");
                         } else {
                             if ($arena instanceof Arena) {
                                 $arena->removePlayer($sender);
                             }
//.........这里部分代码省略.........
开发者ID:Skull3x,项目名称:WonderCore,代码行数:101,代码来源:main.php

示例6: onCommand

 public function onCommand(CommandSender $sender, Command $cmd, $label, array $args)
 {
     switch ($cmd->getName()) {
         case "xyz":
             if ($sender instanceof Player) {
                 $pos = $sender->getPosition();
                 $sender->sendMessage(mc::_("You are at %1%,%2%,%3%", intval($pos->getX()), intval($pos->getY()), intval($pos->getZ())));
             } else {
                 $sender->sendMessage(TextFormat::RED . mc::_("[SignWarp] This command may only be used in-game"));
             }
             return true;
     }
     return false;
 }
开发者ID:DWWf,项目名称:pocketmine-plugins,代码行数:14,代码来源:Main.php

示例7: onCommand

 public function onCommand(CommandSender $i, Command $cmd, $label, array $sub)
 {
     $output = "[EntityManager]";
     switch (array_shift($sub)) {
         case "remove":
             if (!$i->hasPermission("entitymanager.command.remove")) {
                 $i->sendMessage(TextFormat::RED . "You do not have permission to use this command");
                 return true;
             }
             if (isset($sub[0])) {
                 $level = $this->getServer()->getLevelByName($sub[0]);
             } else {
                 $level = $i instanceof Player ? $i->getLevel() : null;
             }
             self::clear([BaseEntity::class, Projectile::class, ItemEntity::class], $level);
             $output .= "All spawned entities were removed";
             break;
         case "check":
             if (!$i->hasPermission("entitymanager.command.check")) {
                 $i->sendMessage(TextFormat::RED . "You do not have permission to use this command");
                 return true;
             }
             $mob = 0;
             $animal = 0;
             $item = 0;
             $projectile = 0;
             $other = 0;
             if (isset($sub[0])) {
                 $level = $this->getServer()->getLevelByName($sub[0]);
             } else {
                 $level = $i instanceof Player ? $i->getLevel() : $this->getServer()->getDefaultLevel();
             }
             foreach ($level->getEntities() as $id => $ent) {
                 if ($ent instanceof Monster) {
                     $mob++;
                 } elseif ($ent instanceof Animal) {
                     $animal++;
                 } elseif ($ent instanceof ItemEntity) {
                     $item++;
                 } elseif ($ent instanceof Projectile) {
                     $projectile++;
                 } elseif (!$ent instanceof Player) {
                     $other++;
                 }
             }
             $output = "--- All entities in Level \"{$level->getName()}\" ---\n";
             $output .= TextFormat::YELLOW . "Monster: {$mob}\n";
             $output .= TextFormat::YELLOW . "Animal: {$animal}\n";
             $output .= TextFormat::YELLOW . "Items: {$item}\n";
             $output .= TextFormat::YELLOW . "Projectiles: {$projectile}\n";
             $output .= TextFormat::YELLOW . "Others: {$other}\n";
             break;
         case "create":
             if (!$i->hasPermission("entitymanager.command.create")) {
                 $i->sendMessage(TextFormat::RED . "You do not have permission to use this command");
                 return true;
             }
             if (!isset($sub[0]) or !is_numeric($sub[0]) and gettype($sub[0]) !== "string") {
                 $output .= "Entity's name is incorrect";
                 break;
             }
             $pos = null;
             if (count($sub) >= 4) {
                 $level = $this->getServer()->getDefaultLevel();
                 if (isset($sub[4]) && ($k = $this->getServer()->getLevelByName($sub[4]))) {
                     $level = $k;
                 } elseif ($i instanceof Player) {
                     $level = $i->getLevel();
                 }
                 $pos = new Position($sub[1], $sub[2], $sub[3], $level);
             } elseif ($i instanceof Player) {
                 $pos = $i->getPosition();
             }
             if ($pos == null) {
                 $output .= "usage: /{$label} create <id/name> (x) (y) (z) (level)";
                 break;
             }
             $entity = self::create($sub[0], $pos);
             if ($entity == null) {
                 $output .= "An error occurred while summoning entity";
                 break;
             }
             $entity->spawnToAll();
             break;
         default:
             $output .= "usage: /{$label} <remove/check/create>";
             break;
     }
     $i->sendMessage($output);
     return true;
 }
开发者ID:steveritter,项目名称:EntityManager,代码行数:91,代码来源:EntityManager.php

示例8: onCommand

 public function onCommand(CommandSender $i, Command $cmd, $label, array $sub)
 {
     $output = "[WorldEditor]";
     if (!$i instanceof Player) {
         return true;
     }
     switch ($cmd->getName()) {
         case "/pos1":
             $pos = $i->floor();
             self::$pos[$i->getName()][0] = $pos;
             $output .= "Pos1 지점을 선택했어요 ({$pos->x}, {$pos->y}, {$pos->z})";
             break;
         case "/pos2":
             $pos = $i->floor();
             self::$pos[$i->getName()][1] = $pos;
             $output .= "Pos2 지점을 선택했어요 ({$pos->x}, {$pos->y}, {$pos->z})";
             break;
         case "/set":
             if (!isset($sub[0])) {
                 $output .= "사용법: //set <id[:meta]>";
                 break;
             }
             if (!isset(self::$pos[$i->getName()]) or count(self::$pos[$i->getName()]) < 2) {
                 $output .= "지역을 먼저 설정해주세요";
                 break;
             }
             $set = explode(":", $sub[0]);
             $block = self::$pos[$i->getName()];
             $endX = max($block[0]->x, $block[1]->x);
             $endY = max($block[0]->y, $block[1]->y);
             $endZ = max($block[0]->z, $block[1]->z);
             $startX = min($block[0]->x, $block[1]->x);
             $startY = min($block[0]->y, $block[1]->y);
             $startZ = min($block[0]->z, $block[1]->z);
             $output .= "블럭 설정을 시작했어요";
             if ($this->getData("debug", false)) {
                 self::core()->getLogger()->info("[WorldEditor]{$i->getName()}님이 블럭설정을 시작했어요");
             }
             $callback = "setBlock";
             $params = [$startX, $startY, $startZ, $endX, $endY, $endZ, Block::get($set[0], isset($set[1]) ? $set[1] : 0, $i->getPosition()), $i];
             break;
         case "/replace":
             if (!isset($sub[0]) or !isset($sub[1])) {
                 $output .= "사용법: //replace <(선택)id[:meta]> <(바꿀)id[:meta>]";
                 break;
             }
             if (!isset(self::$pos[$i->getName()]) or count(self::$pos[$i->getName()]) < 2) {
                 $output .= "지역을 먼저 설정해주세요";
                 break;
             }
             $get = explode(":", $sub[0]);
             $set = explode(":", $sub[1]);
             $block = self::$pos[$i->getName()];
             $endX = max($block[0]->x, $block[1]->x);
             $endY = max($block[0]->y, $block[1]->y);
             $endZ = max($block[0]->z, $block[1]->z);
             $startX = min($block[0]->x, $block[1]->x);
             $startY = min($block[0]->y, $block[1]->y);
             $startZ = min($block[0]->z, $block[1]->z);
             $output .= "블럭 변경을 시작했어요";
             if ($this->getData("debug", false)) {
                 self::core()->getLogger()->info("[WorldEditor]{$i->getName()}님이 블럭변경을 시작했어요");
             }
             $callback = "replaceBlock";
             $params = [$startX, $startY, $startZ, $endX, $endY, $endZ, Block::get($get[0], isset($get[1]) ? $get[1] : 0, $i->getPosition()), Block::get($set[0], isset($set[1]) ? $set[1] : 0, $i->getPosition()), $i];
             break;
         case "/undo":
             if (!isset(self::$pos[$i->getName()]) or count(self::$pos[$i->getName()]) < 2) {
                 $output .= "지역을 먼저 설정해주세요";
                 break;
             }
             $block = self::$pos[$i->getName()];
             $endX = max($block[0]->x, $block[1]->x);
             $endY = max($block[0]->y, $block[1]->y);
             $endZ = max($block[0]->z, $block[1]->z);
             $startX = min($block[0]->x, $block[1]->x);
             $startY = min($block[0]->y, $block[1]->y);
             $startZ = min($block[0]->z, $block[1]->z);
             $output .= "블럭을 되돌리는 중입니다";
             if ($this->getData("debug", false)) {
                 self::core()->getLogger()->info("[WorldEditor]{$i->getName()}님이 블럭을 복구하기 시작했어요");
             }
             $callback = "undoBlock";
             $params = [$startX, $startY, $startZ, $endX, $endY, $endZ, $i];
             break;
         case "/redo":
             if (!isset(self::$pos[$i->getName()]) or count(self::$pos[$i->getName()]) < 2) {
                 $output .= "지역을 먼저 설정해주세요";
                 break;
             }
             $block = self::$pos[$i->getName()];
             $endX = max($block[0]->x, $block[1]->x);
             $endY = max($block[0]->y, $block[1]->y);
             $endZ = max($block[0]->z, $block[1]->z);
             $startX = min($block[0]->x, $block[1]->x);
             $startY = min($block[0]->y, $block[1]->y);
             $startZ = min($block[0]->z, $block[1]->z);
             $output .= "블럭 설정을 시작했어요";
             if ($this->getData("debug", false)) {
                 self::core()->getLogger()->info("[WorldEditor]{$i->getName()}님이 복구한 블럭을 되돌리기 시작했어요");
//.........这里部分代码省略.........
开发者ID:TDMGamingMC,项目名称:WorldEditor,代码行数:101,代码来源:WorldEditor.php

示例9: onCommand

 public function onCommand(CommandSender $i, Command $cmd, $label, array $sub)
 {
     $output = "[EntityManager]";
     switch ($cmd->getName()) {
         case "제거":
             if (isset($sub[0])) {
                 $level = $this->getServer()->getLevelByName($sub[0]);
             } else {
                 $level = $i instanceof Player ? $i->getLevel() : null;
             }
             self::clearEntity($level, [BaseEntity::class, Projectile::class, ItemEntity::class]);
             $output .= "소환된 엔티티를 모두 제거했어요";
             break;
         case "체크":
             $mob = [];
             $animal = [];
             $item = [];
             $projectile = [];
             if (isset($sub[0])) {
                 $level = $this->getServer()->getLevelByName($sub[0]);
             } else {
                 $level = $i instanceof Player ? $i->getLevel() : $this->getServer()->getDefaultLevel();
             }
             foreach ($level->getEntities() as $id => $ent) {
                 if ($ent instanceof Monster) {
                     $mob[$id] = $ent;
                 } elseif ($ent instanceof Animal) {
                     $animal[$id] = $ent;
                 } elseif ($ent instanceof ItemEntity) {
                     $item[$id] = $ent;
                 } elseif ($ent instanceof Projectile) {
                     $projectile[$id] = $ent;
                 }
             }
             $output = "--- Level \"{$level->getName()}\" 에 있는 엔티티 ---\n";
             $output .= TextFormat::YELLOW . "Monster: " . count($mob) . "\n";
             $output .= TextFormat::YELLOW . "Animal: " . count($animal) . "\n";
             $output .= TextFormat::YELLOW . "Items: " . count($item) . "\n";
             $output .= TextFormat::YELLOW . "Projectiles: " . count($projectile) . "\n";
             break;
         case "스폰":
             if (!is_numeric($sub[0]) and gettype($sub[0]) !== "string") {
                 $output .= "엔티티 이름이 올바르지 않아요";
                 break;
             }
             if (count($sub) >= 4) {
                 $level = $this->getServer()->getDefaultLevel();
                 if (isset($sub[4]) && ($k = $this->getServer()->getLevelByName($sub[4]))) {
                     $level = $k;
                 } elseif ($i instanceof Player) {
                     $level = $i->getLevel();
                 }
                 $pos = new Position($sub[1], $sub[2], $sub[3], $level);
             } elseif ($i instanceof Player) {
                 $pos = $i->getPosition();
             }
             if (!isset($pos) || self::createEntity($sub[0], $pos) == null) {
                 $output .= "사용법: /스폰 <id|name> (x) (y) (z) (level)";
             }
             break;
     }
     $i->sendMessage($output);
     return true;
 }
开发者ID:Cybertechpp,项目名称:EntityManager,代码行数:64,代码来源:EntityManager.php


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