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


PHP CommandSender::getName方法代码示例

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


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

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

示例2: onCommand

 public function onCommand(CommandSender $sender, Command $cmd, $label, array $args)
 {
     // TODO: Change command structure
     // TODO: - /action: Please write your command into chat, other players won't be able to see it!
     // TODO: - Use %player% to replace with the player name
     // TODO: - /actionDelAll: Remove all actions assigned to the block
     switch (strtolower($cmd->getName())) {
         case "action":
             if (!$sender instanceof Player) {
                 $sender->sendMessage("This command should not be run on console.");
                 return true;
             }
             $sender->sendMessage("Please tap a block to assign your command.");
             $this->normalSessions[$sender->getName()] = 'action';
             break;
         case "actiondelall":
             if (!$sender instanceof Player) {
                 $sender->sendMessage("This command should not be run on console.");
                 return true;
             }
             $sender->sendMessage("Select the target block to continue.");
             $this->normalSessions[$sender->getName()] = 'actionDelAll';
             break;
         default:
             break;
     }
     return true;
 }
开发者ID:DWWf,项目名称:TapToDo-LEET.CC,代码行数:28,代码来源:TapToDo.php

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

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

示例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 (count($args) === 0) {
         $biomes = TextFormat::WHITE . implode(", ", array_keys($this->biomes));
         $sender->sendMessage($this->translateString("biome.possible", [$biomes]));
         return true;
     } elseif (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 . $this->translateString("notinplot"));
         return true;
     }
     if ($plot->owner !== $sender->getName()) {
         $sender->sendMessage(TextFormat::RED . $this->translateString("notowner"));
         return true;
     }
     if (!isset($this->biomes[$biome])) {
         $sender->sendMessage(TextFormat::RED . $this->translateString("biome.invalid"));
         $biomes = implode(", ", array_keys($this->biomes));
         $sender->sendMessage(TextFormat::RED . $this->translateString("biome.possible", [$biomes]));
         return true;
     }
     $biome = Biome::getBiome($this->biomes[$biome]);
     if ($this->getPlugin()->setPlotBiome($plot, $biome)) {
         $sender->sendMessage($this->translateString("biome.success", [$biome->getName()]));
     } else {
         $sender->sendMessage(TextFormat::RED . $this->translateString("error"));
     }
     return true;
 }
开发者ID:Adam1609,项目名称:MyPlot,代码行数:34,代码来源:BiomeSubCommand.php

示例7: exec

 public function exec(CommandSender $sender, array $args)
 {
     $username = $sender->getName();
     $result = $this->getPlugin()->myMoney($username);
     $sender->sendMessage($this->getPlugin()->getMessage("mymoney-mymoney", $sender->getName(), array($result, "%2", "%3", "%4")));
     return true;
 }
开发者ID:Tolo0,项目名称:EconomyS,代码行数:7,代码来源:MyMoneyCommand.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: onCommand

 public function onCommand(CommandSender $sender, Command $command, $label, array $args)
 {
     if ($command->getName() === "tc") {
         if (!isset($args[0])) {
             $sender->sendMessage("/tc add <command> : Add command to a block.");
             $sender->sendMessage("/tc delete : Deletes commands from block.");
             return true;
         } elseif ($args[0] === "add") {
             if (!isset($args[1])) {
                 $sender->sendMessage("/tc add <command>");
                 return true;
             } else {
                 $moved_args = array();
                 foreach ($args as $argss) {
                     array_push($moved_args, $argss);
                 }
                 unset($moved_args[array_search("add", $moved_args)]);
                 $command = implode(" ", $moved_args);
                 array_push($this->tapwait, array("plyr" => $sender->getName(), "command" => $command));
                 $sender->sendMessage("Tap on the block to add the command to..");
                 return true;
             }
         } elseif ($args[0] == "delete") {
             if (!isset($args[1])) {
                 $sender->sendMessage("/tc delete");
                 return true;
             } else {
                 array_push($this->tapwait, array("plyrv" => $sender->getName(), "dell" => "yes"));
                 $sender->sendMessage("Tap on the block to delete commands from..");
                 return true;
             }
         }
     }
 }
开发者ID:HotFireyDeath,项目名称:PM-Plugins,代码行数:34,代码来源:TapCommand.php

示例10: execute

 public function execute(CommandSender $sender, array $args)
 {
     if (empty($args)) {
         $plotNumber = 1;
     } elseif (count($args) === 1 and is_numeric($args[0])) {
         $plotNumber = (int) $args[0];
     } else {
         return false;
     }
     $plots = $this->getPlugin()->getProvider()->getPlotsByOwner($sender->getName());
     if (empty($plots)) {
         $sender->sendMessage(TextFormat::RED . "You don't have any plots");
         return true;
     }
     if (!isset($plots[$plotNumber - 1])) {
         $sender->sendMessage(TextFormat::RED . "You don't have a plot with home number {$plotNumber}");
         return true;
     }
     $player = $this->getPlugin()->getServer()->getPlayer($sender->getName());
     $plot = $plots[$plotNumber - 1];
     if ($this->getPlugin()->teleportPlayerToPlot($player, $plot)) {
         $sender->sendMessage(TextFormat::GREEN . "Teleported to " . TextFormat::WHITE . $plot);
     } else {
         $sender->sendMessage(TextFormat::GREEN . "Could not teleport because plot world " . $plot->levelName . " is not loaded");
     }
     return true;
 }
开发者ID:kdani1,项目名称:PEPlot,代码行数:27,代码来源:HomeSubCommand.php

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

示例12: onCommand

 public function onCommand(CommandSender $sender, Command $command, $label, array $args)
 {
     if (strtolower($command->getName()) === "buyworld") {
         if (count($args) < 1 || count($args) > 4) {
             return false;
         }
         if (EconomyAPI::getInstance()->myMoney($sender->getName()) < 10000) {
             $sender->sendMessage(TextFormat::RED . "[HyperPlot] You don't have enought money. It cost \$10000");
             return true;
         }
         $world = array_shift($args);
         if (strlen($world) < 3) {
             $sender->sendMessage(TextFormat::RED . "[HyperPlot] Small World name");
             return true;
         }
         if ($this->getServer()->isLevelGenerated($world)) {
             $sender->sendMessage(TextFormat::RED . "[HyperPlot] A world named " . $world . " already exists");
             return true;
         }
         EconomyAPI::getInstance()->reduceMoney($sender->getName(), 10000);
         $this->getServer()->broadcastMessage($sender->sendMessage(TextFormat::RED . "[HyperPlot]  Creating level " . $sender->getName() . "-" . $world . "..."));
         $generator = Generator::getGenerator("ownworld");
         $this->getServer()->generateLevel($sender->getName() . "-" . $world, null, $generator, []);
         $this->getServer()->loadLevel($sender->getName() . "-" . $world);
         return true;
     }
     return false;
 }
开发者ID:Gumbrat,项目名称:Pocketmine-Plugins,代码行数:28,代码来源:HyperPlotWorld.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: onCommand

 public function onCommand(CommandSender $sender, Command $command, $label, array $params)
 {
     $username = strtolower($sender->getName());
     $player = $this->getServer()->getPlayer($username);
     if (!$player instanceof Player) {
         $sender->sendMessage("Use this command in-game!");
         return true;
     }
     switch ($command->getName()) {
         case "pvppon":
             $this->getConfig()->set(strtolower($sender->getName()), true);
             $this->getConfig()->save();
             $sender->sendMessage("PvP enabled for you.\nUse '/pvppoff' for disable.");
             break;
         case "pvppoff":
             $this->getConfig()->set(strtolower($sender->getName()), false);
             $this->getConfig()->save();
             $sender->sendMessage("PvP disabled for you.\nUse '/pvppon' for enable.");
             break;
         case "pvpp":
             if ($this->getConfig()->get(strtolower($sender->getName()))) {
                 $sender->sendMessage("How PvP enabled for you.\nUse '/pvppoff' for disable.");
             } else {
                 $sender->sendMessage("How PvP disabled for you.\nUse '/pvppon' for enable.");
             }
             break;
     }
     return true;
 }
开发者ID:alex2534alex,项目名称:PocketMinePlugins,代码行数:29,代码来源:pvpplayer.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 . "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


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