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


PHP CommandSender::getLevel方法代码示例

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


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

示例1: 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;
 }
开发者ID:Skull3x,项目名称:MineBlock,代码行数:34,代码来源:TeleportView.php

示例2: execute

 public function execute(CommandSender $sender, array $args)
 {
     if (!$sender instanceof Player) {
         $sender->sendMessage(TextFormat::YELLOW . "Please run this command in game!");
         return true;
     }
     $this->getMain()->selection[strtolower($sender->getName())]["pos2"] = ["x" => $sender->getFloorX(), "z" => $sender->getFloorZ(), "level" => $sender->getLevel()->getName()];
     $sender->sendMessage(TextFormat::GREEN . "Pos 2 set to : x=" . $sender->getFloorX() . ", z=" . $sender->getFloorZ() . ", level=" . $sender->getLevel()->getName());
     return true;
 }
开发者ID:EmreTr1,项目名称:TNTRun,代码行数:10,代码来源:Pos2SubCmd.php

示例3: execute

 public function execute(CommandSender $sender, array $args)
 {
     if (!$sender instanceof Player) {
         $sender->sendMessage($this->getMessage("error.in-game"));
         return true;
     }
     $this->getMain()->selection[strtolower($sender->getName())]["pos2"] = ["x" => $sender->getFloorX(), "z" => $sender->getFloorZ(), "level" => $sender->getLevel()->getName()];
     $sender->sendMessage($this->getMessage("commands.pos2.set", ["POS" => "x=" . $sender->getFloorX() . ", z=" . $sender->getFloorZ() . ", level=" . $sender->getLevel()->getName()]));
     return true;
 }
开发者ID:100henrik100,项目名称:TNTRun,代码行数:10,代码来源:Pos2SubCmd.php

示例4: onCommand

 public function onCommand(CommandSender $sender, Command $command, $label, array $args)
 {
     if (strtolower($command->{$getName}()) == "closest") {
         if ($sender instanceof Position) {
             // if the sender is a position, for example a player
             $closest = null;
             $lastSquare = -1;
             foreach ($sender->getLevel()->getPlayers() as $p) {
                 // for every player in the sender's world
                 if ($p !== $sender) {
                     $square = $sender->distanceSquared($p);
                     // get the square of the distance between the sender and the currently checking player
                     // use distanceSquared() because it is faster than distance()
                     if ($lastSquare === -1 or $lastSquare > $square) {
                         // this is the so far closest player
                         $closest = $p;
                         $lastSquare = $square;
                     }
                 }
             }
             if ($sender instanceof Player) {
                 $sender->sendMessage("The closest player to you is" . $closest);
             }
         }
     }
 }
开发者ID:somenabzofturtles,项目名称:Small-PM-Plugins,代码行数:26,代码来源:Main.php

示例5: 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;
 }
开发者ID:stoastye85,项目名称:Plugins,代码行数:32,代码来源:TeleportView.php

示例6: onCommand

 public function onCommand(CommandSender $sender, Command $cmd, $label, array $args)
 {
     if ($cmd->getName() != "motd") {
         return false;
     }
     if ($sender instanceof Player) {
         $world = $sender->getLevel()->getName();
     } else {
         $level = $this->owner->getServer()->getDefaultLevel();
         if ($level) {
             $world = $level->getName();
         } else {
             $world = null;
         }
     }
     if (isset($args[0]) && $this->owner->getServer()->isLevelGenerated($args[0])) {
         $world = array_shift($args);
     }
     if ($world === null) {
         $sender->sendMessage(mc::_("[WP] Must specify a world"));
         return false;
     }
     if (count($args) != 0) {
         return false;
     }
     $this->showMotd($sender, $world);
     return true;
 }
开发者ID:DWWf,项目名称:pocketmine-plugins,代码行数:28,代码来源:WpMotdMgr.php

示例7: onCommand

 public function onCommand(CommandSender $issuer, Command $cmd, $label, array $args)
 {
     switch ($cmd->getName()) {
         case "setjail":
             if ($issuer->hasPermission("jail.command") !== true && $issuer->hasPermission("jail.command.setjail") !== true) {
                 $issuer->sendMessage($this->plugin->colourMessage("&cYou don't have permission for this!"));
                 return true;
             }
             if (!isset($args[0])) {
                 return false;
             }
             $jail = $args[0];
             if ($this->plugin->jailExists($jail) !== false) {
                 $issuer->sendMessage($this->plugin->colourMessage("&cJail already exists!"));
                 return true;
             }
             if (!$issuer instanceof Player) {
                 $issuer->sendMessage($this->plugin->colourMessage("Command only works in-game!"));
                 return true;
             }
             $this->plugin->setJail($jail, $issuer->x, $issuer->y, $issuer->z, $issuer->getLevel());
             $issuer->sendMessage($this->plugin->colourMessage("&6You created jail: &c" . $jail . "&6!"));
             return true;
             break;
     }
 }
开发者ID:HerO-0110,项目名称:Jail,代码行数:26,代码来源:SetjailCommand.php

示例8: execute

 public function execute(CommandSender $sender, $currentAlias, array $args)
 {
     if (count($args) < 1) {
         $sender->sendMessage(new TranslationContainer("commands.generic.usage", [$this->usageMessage]));
         return false;
     }
     if ($sender instanceof Player) {
         $wea = (int) $args[0];
         if ($wea >= 0 and $wea <= 3) {
             if (WeatherManager::isRegistered($sender->getLevel())) {
                 $sender->getLevel()->getWeather()->setWeather($wea);
                 $sender->sendMessage(TextFormat::GREEN . "天气设置成功!");
                 return true;
             } else {
                 $sender->sendMessage(TextFormat::RED . "这个世界没有注册到天气管理器!");
                 return false;
             }
         } else {
             $sender->sendMessage(TextFormat::RED . "无效的天气!");
             return false;
         }
     }
     if (count($args) < 2) {
         $sender->sendMessage(TextFormat::RED . "缺少参数!");
         return false;
     }
     $level = $sender->getServer()->getLevelByName($args[0]);
     if (!$level instanceof Level) {
         $sender->sendMessage(TextFormat::RED . "错误的地图名!");
         return false;
     }
     $wea = (int) $args[1];
     if ($wea >= 0 and $wea <= 3) {
         if (WeatherManager::isRegistered($level)) {
             $level->getWeather()->setWeather($wea);
             $sender->sendMessage(TextFormat::GREEN . "天气设置成功!");
             return true;
         } else {
             $sender->sendMessage(TextFormat::RED . "这个世界没有注册到天气管理器!");
             return false;
         }
     } else {
         $sender->sendMessage(TextFormat::RED . "无效的天气!");
         return false;
     }
     return true;
 }
开发者ID:1455931078,项目名称:Genisys,代码行数:47,代码来源:WeatherCommand.php

示例9: parseVars

 public function parseVars($message, CommandSender $sender) : string
 {
     $level = $sender instanceof Player ? $sender->getLevel() : $this->plugin->getServer()->getDefaultLevel();
     $replace = ["&", "{maxplayers}", "{playercount}", "{name}", "{playerlevel}", "{playerlevelcount}"];
     $with = ["§", $this->plugin->getServer()->getMaxPlayers(), count($this->plugin->getServer()->getOnlinePlayers()), $sender instanceof Player ? $sender->getName() : "CONSOLE", $level->getName(), count($level->getPlayers())];
     $message = str_replace($replace, $with, $message);
     return $message;
 }
开发者ID:MCrafterss,项目名称:MHelpModifer,代码行数:8,代码来源:ModifedHelpCommand.php

示例10: format

 public function format(Server $server, CommandSender $sender, $name, array $args)
 {
     if ($sender instanceof Position) {
         // command blocks?
         return $sender->getLevel()->getName();
     }
     return false;
 }
开发者ID:barnseyminesuk,项目名称:Small-ZC-Plugins,代码行数:8,代码来源:WorldSelector.php

示例11: 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;
 }
开发者ID:ecoron,项目名称:SpawnPort,代码行数:13,代码来源:SpawnPort.php

示例12: execute

 public function execute(CommandSender $sender, $commandLabel, array $args)
 {
     if ($sender instanceof Player) {
         $sender->sendMessage("You are at {$sender->x},{$sender->y},{$sender->z};{$sender->yaw},{$sender->pitch}@{$sender->getLevel()->getName()}");
     } else {
         if (!isset($args[0])) {
             $sender->sendMessage("Usage: /getpos <player>");
             return true;
         }
         $player = $this->getPlugin()->getServer()->getPlayer($args[0]);
         if ($player instanceof Player) {
             $sender->sendMessage($player->getName() . " is at {$player->x},{$player->y},{$player->z};{$player->yaw},{$player->pitch}@{$player->getLevel()->getName()}");
         } else {
             $sender->sendMessage("Player {$args['0']} not found");
         }
     }
     return true;
 }
开发者ID:LegionPE,项目名称:LegionPE-Eta,代码行数:18,代码来源:GetPosCommand.php

示例13: onCommand

 public function onCommand(CommandSender $sender, Command $command, $label, array $args)
 {
     switch ($command->getName()) {
         case "pos":
             if ($sender instanceof Player) {
                 $playerX = $sender->getX();
                 $playerY = $sender->getY();
                 $playerZ = $sender->getZ();
                 $outX = round($playerX, 1);
                 $outY = round($playerY, 1);
                 $outZ = round($playerZ, 1);
                 $playerLevel = $sender->getLevel()->getName();
                 $sender->sendMessage(TextFormat::BLUE . " x:" . TextFormat::GREEN . $outX . ", y:" . TextFormat::YELLOW . $outY . ", z:" . TextFormat::GREEN . $outZ . ". On: " . TextFormat::AQUA . $playerLevel);
                 return true;
             } else {
                 $sender->sendMessage("§cThis command only works §ein§f-§egame.");
             }
     }
 }
开发者ID:ChiefArtz,项目名称:SpazzyTp,代码行数:19,代码来源:Main.php

示例14: onCommand

 public function onCommand(CommandSender $sender, Command $command, $label, array $args)
 {
     switch ($command->getName()) {
         case "greenify":
             if (count($args) !== 0) {
                 $sender->sendMessage(TextFormat::RED . "Usage: " . $command->getUsage());
                 return true;
             }
             $sender->sendMessage("Prepare for a lag spike!");
             $level = $sender->getLevel();
             $playerX = $sender->getFloorX();
             $playerZ = $sender->getFloorZ();
             for ($x = $playerX - 100; $x <= $playerX + 100; $x++) {
                 for ($z = $playerZ - 100; $z <= $playerZ + 100; $z++) {
                     $level->setBiomeColor($x, $z, 127, 169, 76);
                 }
             }
             return true;
     }
 }
开发者ID:Calrizer,项目名称:Greenifier,代码行数:20,代码来源:Greenifier.php

示例15: onCommand

 /**
  * @param CommandSender $sender
  * @param Command $cmd
  * @param $label
  * @param array $args
  * @return bool
  */
 public function onCommand(CommandSender $sender, Command $cmd, $label, array $args)
 {
     switch (strtolower($cmd->getName())) {
         case 'rand':
             foreach ($this->getConfig()->get("Worlds") as $world) {
                 if ($sender->hasPermission("randtp.rand")) {
                     if ($sender instanceof Player && $sender->getLevel()->getName() !== $world) {
                         $this->toRand($sender, self::RANDOM_TP);
                         $sender->sendMessage(TXT::AQUA . "Teleported to X: " . TXT::YELLOW . $sender->getX() . TXT::AQUA . ", Y: " . TXT::YELLOW . $sender->getY() . TXT::AQUA . " Z: " . TXT::YELLOW . $sender->getZ());
                     } elseif (!$sender instanceof Player) {
                         $sender->sendMessage(TXT::RED . "Please run this command in game.");
                         return true;
                     } elseif ($sender->getLevel()->getName() === $world) {
                         $sender->sendMessage(TXT::RED . "You are not allowed to use that command in this world.");
                         return true;
                     }
                 }
             }
             break;
     }
 }
开发者ID:Artide,项目名称:PM-1.5-Plugins,代码行数:28,代码来源:RandTP.php


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