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


PHP CommandSender::getServer方法代码示例

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


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

示例1: onCommand

 public function onCommand(CommandSender $sender, Command $cmd, $label, array $args)
 {
     if (strtolower($cmd->getName('cratekey'))) {
         if (count($args) == 0) {
             $sender->sendMessage(TextFormat::RED . "/cratekey <give/giveall>");
         }
         if (count($args) == 1) {
             if ($args[0] == "giveall") {
                 if ($sender->hasPermission("mysterycrates.command.cratekey.giveall")) {
                     $this->plugin->giveCratekeyAll();
                     $sender->sendMessage(TextFormat::GOLD . "You have given a cratekey to everyone on the server!");
                     $sender->getServer()->broadcastMessage(TextFormat::BOLD . TextFormat::BLUE . "[MysteryCrates]" . TextFormat::GREEN . TextFormat::RESET . " Everyone has been given a cratekey by " . TextFormat::GOLD . $sender->getName() . "! ");
                 }
             }
         }
         if (count($args) == 2) {
             if ($args[0] == "give") {
                 if ($sender->hasPermission("mysterycrates.command.cratekey.give")) {
                     $player = $sender->getServer()->getPlayer($args[1]);
                     if ($player instanceof Player) {
                         $player->sendMessage(TextFormat::GREEN . "You have been given a cratekey by " . TextFormat::GOLD . $sender->getName());
                         $sender->sendMessage(TextFormat::GOLD . "Given a cratekey to " . TextFormat::GOLD . $player->getName());
                         $this->plugin->giveCratekey($player);
                     } else {
                         $sender->sendMessage(TextFormat::RED . "That player cannot be found");
                     }
                 }
             }
         }
     }
 }
开发者ID:ChiefArtz,项目名称:MysteryCrates,代码行数:31,代码来源:CratekeyCommand.php

示例2: processIPBan

 private function processIPBan($ip, CommandSender $sender, $reason)
 {
     $sender->getServer()->getIPBans()->addBan($ip, $reason, null, $sender->getName());
     foreach ($sender->getServer()->getOnlinePlayers() as $player) {
         if ($player->getAddress() === $ip) {
             $player->kick("You have been IP banned.");
         }
     }
     Command::broadcastCommandMessage($sender, "Banned IP Address " . $ip);
 }
开发者ID:boybook,项目名称:PocketMine-MP,代码行数:10,代码来源:BanIpCommand.php

示例3: processIPBan

 private function processIPBan($ip, CommandSender $sender, $reason)
 {
     $sender->getServer()->getIPBans()->addBan($ip, $reason, \null, $sender->getName());
     foreach ($sender->getServer()->getOnlinePlayers() as $player) {
         if ($player->getAddress() === $ip) {
             $player->kick($reason !== "" ? $reason : "IP banned.");
         }
     }
     $sender->getServer()->getNetwork()->blockAddress($ip, -1);
 }
开发者ID:xpyctum,项目名称:PocketMinePlusPlus,代码行数:10,代码来源:BanIpCommand.php

示例4: execute

 public function execute(CommandSender $sender, $commandLabel, array $args)
 {
     $dist = 0;
     if (count($args) === 0) {
         $sender->sendMessage("Usage: /dtp [from] <to>[-<distance behind <to>>]");
         return;
     } elseif (count($args) === 1) {
         if (!($from = $sender) instanceof Player) {
             $sender->sendMessage("Please run this command in-game.");
             return;
         }
         $toName = $args[0];
         $pos = strpos($toName, "-");
         if ($pos !== false) {
             $dist = (int) substr($toName, $pos + 1);
             $toName = substr($toName, 0, $pos);
         }
         $to = $sender->getServer()->getPlayer($toName);
         if (!$to instanceof Player) {
             $sender->sendMessage("{$toName} isn't online!");
             return;
         }
     } else {
         $from = $sender->getServer()->getPlayer($args[0]);
         if (!$from instanceof Player) {
             $sender->sendMessage("{$args['0']} isn't online!");
             return;
         }
         $toName = $args[1];
         $pos = strpos($toName, "-");
         if ($pos !== false) {
             $dist = (int) substr($toName, $pos + 1);
             $toName = substr($toName, 0, $pos);
         }
         $to = $sender->getServer()->getPlayer($toName);
         if (!$to instanceof Player) {
             $sender->sendMessage("{$toName} isn't online!");
             return;
         }
     }
     $l = $to->getLevel();
     $v3 = $to->subtract($to->getDirectionVector()->multiply($dist))->floor();
     for ($i = $v3->y; $i < 128; $v3->y = ++$i) {
         $b = $l->getBlock($v3);
         $id = $b->getId();
         if ($id === 0 or 8 <= $id and $id <= 11) {
             break;
         }
     }
     $from->teleport(Position::fromObject($v3, $l));
     $from->sendMessage("Teleported to {$to->getName()}");
 }
开发者ID:LegionPE,项目名称:LegionPE-Eta,代码行数:52,代码来源:DirectTpCommand.php

示例5: execute

 public function execute(CommandSender $sender, array $args)
 {
     if (!empty($args)) {
         return false;
     }
     $player = $sender->getServer()->getPlayer($sender->getName());
     $plot = $this->getPlugin()->getPlotByPosition($player->getPosition());
     if ($plot === null) {
         $sender->sendMessage(TextFormat::RED . $this->translateString("notinplot"));
         return true;
     }
     if ($plot->owner !== $sender->getName() and !$sender->hasPermission("myplot.admin.reset")) {
         $sender->sendMessage(TextFormat::RED . $this->translateString("notowner"));
         return true;
     }
     $economy = $this->getPlugin()->getEconomyProvider();
     $price = $this->getPlugin()->getLevelSettings($plot->levelName)->resetPrice;
     if ($economy !== null and !$economy->reduceMoney($player, $price)) {
         $sender->sendMessage(TextFormat::RED . $this->translateString("reset.nomoney"));
         return true;
     }
     if ($this->getPlugin()->resetPlot($plot)) {
         $sender->sendMessage($this->translateString("reset.success"));
     } else {
         $sender->sendMessage(TextFormat::RED . $this->translateString("error"));
     }
     return true;
 }
开发者ID:gitter-badger,项目名称:MyPlot,代码行数:28,代码来源:ResetSubCommand.php

示例6: execute

 public function execute(CommandSender $sender, array $args)
 {
     if (!empty($args)) {
         return false;
     }
     $player = $sender->getServer()->getPlayer($sender->getName());
     $plot = $this->getPlugin()->getPlotByPosition($player->getPosition());
     if ($plot === null) {
         $sender->sendMessage(TextFormat::RED . "You are not standing on an island");
         return true;
     }
     if ($plot->owner !== $sender->getName() and !$sender->hasPermission("skyblock.admin.clear")) {
         $sender->sendMessage(TextFormat::RED . "You are not the owner of this island");
         return true;
     }
     $economy = $this->getPlugin()->getEconomyProvider();
     $price = $this->getPlugin()->getLevelSettings($plot->levelName)->clearPrice;
     if ($economy !== null and !$economy->reduceMoney($player, $price)) {
         $sender->sendMessage(TextFormat::RED . "You don't have enough money to clear this island");
         return true;
     }
     if ($this->getPlugin()->clearPlot($plot, $player)) {
         $sender->sendMessage("Island is being cleared...");
     } else {
         $sender->sendMessage(TextFormat::RED . "Could not clear this island");
     }
     return true;
 }
开发者ID:RedstoneAlmeida,项目名称:SkyBlockPE,代码行数:28,代码来源:ClearSubCommand.php

示例7: execute

 public function execute(CommandSender $sender, array $args)
 {
     if (!empty($args)) {
         return false;
     }
     $player = $sender->getServer()->getPlayer($sender->getName());
     $levelName = $player->getLevel()->getName();
     $plots = $this->getPlugin()->getProvider()->getPlotsByOwner($sender->getName());
     if (empty($plots)) {
         $sender->sendMessage(TextFormat::RED . $this->translateString("homes.noplots"));
         return true;
     }
     $sender->sendMessage(TextFormat::DARK_GREEN . $this->translateString("homes.header"));
     usort($plots, function ($plot1, $plot2) {
         /** @var $plot1 Plot */
         /** @var $plot2 Plot */
         if ($plot1->levelName == $plot2->levelName) {
             return 0;
         }
         return $plot1->levelName < $plot2->levelName ? -1 : 1;
     });
     for ($i = 0; $i < count($plots); $i++) {
         $plot = $plots[$i];
         $message = TextFormat::DARK_GREEN . ($i + 1) . ") ";
         $message .= TextFormat::WHITE . $levelName . " " . $plot;
         if ($plot->name !== "") {
             $message .= " = " . $plot->name;
         }
         $sender->sendMessage($message);
     }
     return true;
 }
开发者ID:Adam1609,项目名称:MyPlot,代码行数:32,代码来源:HomesSubCommand.php

示例8: execute

 public function execute(CommandSender $sender, array $args)
 {
     if (count($args) !== 1) {
         return false;
     }
     $player = $sender->getServer()->getPlayer($sender->getName());
     $biome = strtoupper($args[0]);
     $plot = $this->getPlugin()->getPlotByPosition($player->getPosition());
     if ($plot === null) {
         $sender->sendMessage(TextFormat::RED . "You are not standing on an island");
         return true;
     }
     if ($plot->owner !== $sender->getName()) {
         $sender->sendMessage(TextFormat::RED . "You are not the owner of this island");
         return true;
     }
     if (!isset($this->biomes[$biome])) {
         $sender->sendMessage(TextFormat::RED . "That biome doesn't exist");
         $biomes = implode(", ", array_keys($this->biomes));
         $sender->sendMessage(TextFormat::RED . "The possible biomes are: {$biomes}");
         return true;
     }
     $biome = Biome::getBiome($this->biomes[$biome]);
     if ($this->getPlugin()->setPlotBiome($plot, $biome)) {
         $sender->sendMessage(TextFormat::GREEN . "Changed the island biome");
     } else {
         $sender->sendMessage(TextFormat::RED . "Could not change the island biome");
     }
     return true;
 }
开发者ID:RedstoneAlmeida,项目名称:SkyBlockPE,代码行数:30,代码来源:BiomeSubCommand.php

示例9: execute

 public function execute(CommandSender $sender, array $args)
 {
     if (count($args) != 1) {
         return false;
     }
     $player = $sender->getServer()->getPlayer($sender->getName());
     $levelName = $player->getLevel()->getName();
     if (!$this->getPlugin()->isLevelLoaded($levelName)) {
         $sender->sendMessage(TextFormat::RED . $this->translateString("warp.notinplotworld"));
         return true;
     }
     $plotIdArray = explode(";", $args[0]);
     if (count($plotIdArray) != 2 or !is_numeric($plotIdArray[0]) or !is_numeric($plotIdArray[1])) {
         $sender->sendMessage(TextFormat::RED . $this->translateString("warp.wrongid"));
         return true;
     }
     $plot = $this->getPlugin()->getProvider()->getPlot($levelName, $plotIdArray[0], $plotIdArray[1]);
     if ($plot->owner == "" and !$sender->hasPermission("myplot.admin.warp")) {
         $sender->sendMessage(TextFormat::RED . $this->translateString("warp.unclaimed"));
         return true;
     }
     $this->getPlugin()->teleportPlayerToPlot($player, $plot);
     $plot = TextFormat::GREEN . $plot . TextFormat::WHITE;
     $sender->sendMessage($this->translateString("warp.success", [$plot]));
     return true;
 }
开发者ID:Adam1609,项目名称:MyPlot,代码行数:26,代码来源:WarpSubCommand.php

示例10: execute

 public function execute(CommandSender $sender, array $args)
 {
     if (count($args) !== 1) {
         return false;
     }
     $helper = $args[0];
     $player = $sender->getServer()->getPlayer($sender->getName());
     $plot = $this->getPlugin()->getPlotByPosition($player->getPosition());
     if ($plot === null) {
         $sender->sendMessage(TextFormat::RED . "You are not standing inside a plot");
         return true;
     }
     if ($plot->owner !== $sender->getName() and !$sender->hasPermission("myplot.admin.addhelper")) {
         $sender->sendMessage(TextFormat::RED . "You are not the owner of this plot");
         return true;
     }
     if (!$plot->addHelper($helper)) {
         $sender->sendMessage($helper . " was already a helper of this plot");
         return true;
     }
     if ($this->getPlugin()->getProvider()->savePlot($plot)) {
         $sender->sendMessage(TextFormat::GREEN . $helper . " is now a helper of this plot");
     } else {
         $sender->sendMessage(TextFormat::RED . "Helper could not be added");
     }
     return true;
 }
开发者ID:kdani1,项目名称:PEPlot,代码行数:27,代码来源:AddHelperSubCommand.php

示例11: 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

示例12: execute

 public function execute(CommandSender $sender, array $args)
 {
     $confirm = (count($args) == 1 and $args[0] == $this->translateString("confirm"));
     if (count($args) != 0 and !$confirm) {
         return false;
     }
     $player = $sender->getServer()->getPlayer($sender->getName());
     $plot = $this->getPlugin()->getPlotByPosition($player->getPosition());
     if ($plot === null) {
         $sender->sendMessage(TextFormat::RED . $this->translateString("notinplot"));
         return true;
     }
     if ($plot->owner !== $sender->getName() and !$sender->hasPermission("myplot.admin.reset")) {
         $sender->sendMessage(TextFormat::RED . $this->translateString("notowner"));
         return true;
     }
     if ($confirm) {
         $economy = $this->getPlugin()->getEconomyProvider();
         $price = $this->getPlugin()->getLevelSettings($plot->levelName)->resetPrice;
         if ($economy !== null and !$economy->reduceMoney($player, $price)) {
             $sender->sendMessage(TextFormat::RED . $this->translateString("reset.nomoney"));
             return true;
         }
         $maxBlocksPerTick = $this->getPlugin()->getConfig()->get("ClearBlocksPerTick", 256);
         if ($this->getPlugin()->resetPlot($plot, $maxBlocksPerTick)) {
             $sender->sendMessage($this->translateString("reset.success"));
         } else {
             $sender->sendMessage(TextFormat::RED . $this->translateString("error"));
         }
     } else {
         $plotId = TextFormat::GREEN . $plot . TextFormat::WHITE;
         $sender->sendMessage($this->translateString("reset.confirm", [$plotId]));
     }
     return true;
 }
开发者ID:Adam1609,项目名称:MyPlot,代码行数:35,代码来源:ResetSubCommand.php

示例13: execute

 public function execute(CommandSender $sender, array $args)
 {
     if (count($args) !== 1) {
         return false;
     }
     $helper = $args[0];
     $player = $sender->getServer()->getPlayer($sender->getName());
     $plot = $this->getPlugin()->getPlotByPosition($player->getPosition());
     if ($plot === null) {
         $sender->sendMessage(TextFormat::RED . "You are not standing inside a plot");
         return true;
     }
     if ($plot->owner !== $sender->getName()) {
         $sender->sendMessage(TextFormat::RED . "You are not the owner of this plot");
         return true;
     }
     if (!$plot->removeHelper($helper)) {
         $sender->sendMessage($helper . " was never a helper of this plot.");
         return true;
     }
     if ($this->getPlugin()->getProvider()->savePlot($plot)) {
         $sender->sendMessage(TextFormat::GREEN . $helper . " has been removed.");
     } else {
         $sender->sendMessage(TextFormat::RED . "Could not remove that player.");
     }
     return true;
 }
开发者ID:boy0001,项目名称:MyPlot,代码行数:27,代码来源:RemoveHelperSubCommand.php

示例14: execute

 public function execute(CommandSender $sender, $commandLabel, array $args)
 {
     $commands = [];
     $result = false;
     foreach ($this->formatStrings as $formatString) {
         try {
             $commands[] = $this->buildCommand($formatString, $args);
         } catch (\Exception $e) {
             if ($e instanceof \InvalidArgumentException) {
                 $sender->sendMessage(TextFormat::RED . $e->getMessage());
             } else {
                 $sender->sendMessage(new TranslationContainer(TextFormat::RED . "%commands.generic.exception"));
                 $logger = $sender->getServer()->getLogger();
                 if ($logger instanceof MainLogger) {
                     $logger->logException($e);
                 }
             }
             return false;
         }
     }
     foreach ($commands as $command) {
         $result |= Server::getInstance()->dispatchCommand($sender, $command);
     }
     return (bool) $result;
 }
开发者ID:wrewolf,项目名称:ImagicalMine,代码行数:25,代码来源:FormattedCommandAlias.php

示例15: execute

 public function execute(CommandSender $sender, array $args)
 {
     if (count($args) !== 1) {
         return false;
     }
     $helper = $args[0];
     $player = $sender->getServer()->getPlayer($sender->getName());
     $plot = $this->getPlugin()->getPlotByPosition($player->getPosition());
     if ($plot === null) {
         $sender->sendMessage(TextFormat::RED . $this->translateString("notinplot"));
         return true;
     }
     if ($plot->owner !== $sender->getName() and !$sender->hasPermission("myplot.admin.removehelper")) {
         $sender->sendMessage(TextFormat::RED . $this->translateString("notowner"));
         return true;
     }
     if (!$plot->removeHelper($helper)) {
         $sender->sendMessage(TextFormat::RED . $this->translateString("removehelper.notone", [$helper]));
         return true;
     }
     if ($this->getPlugin()->getProvider()->savePlot($plot)) {
         $sender->sendMessage($this->translateString("removehelper.success", [$helper]));
     } else {
         $sender->sendMessage(TextFormat::RED . $this->translateString("error"));
     }
     return true;
 }
开发者ID:gitter-badger,项目名称:MyPlot,代码行数:27,代码来源:RemoveHelperSubCommand.php


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