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


PHP CommandSender::getDisplayName方法代码示例

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


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

示例1: onCommand

 public function onCommand(CommandSender $sender, Command $cmd, $label, array $args)
 {
     if (strtolower($cmd->getName()) === "warn") {
         if (!(isset($args[0]) and isset($args[1]))) {
             $sender->sendMessage(TF::RED . "Error: not enough args. Usage: /warn <player> < reason >");
             return true;
         } else {
             $name = $args[0];
             $player = $this->getServer()->getPlayer($name);
             $player_name = $player->getName();
             $sender_name = $sender->getName();
             $sender_display_name = $sender->getDisplayName();
             unset($args[0]);
             $reason = implode(" ", $args);
             if ($player === null) {
                 $sender->sendMessage(TF::RED . "Player " . $name . " could not be found.");
                 return true;
             } else {
                 $player->sendMessage(TF::RED . "You have been warned by " . $sender_name . " for " . $reason);
                 $sender->sendMessage(TF::GREEN . "You have warned " . $player_name . " for " . $reason);
                 $this->getServer()->broadcastMessage(TF::YELLOW . $player_name . " has been warned by " . $sender_name . " for " . $reason);
                 return true;
             }
         }
     }
 }
开发者ID:applqpak,项目名称:WarnPlayer,代码行数:26,代码来源:Main.php

示例2: onCommand

 public function onCommand(CommandSender $sender, Command $cmd, $label, array $args)
 {
     if (strtolower($cmd->getName()) === "report") {
         if (!isset($args[0])) {
             $sender->sendMessage(TF::RED . "Error: not enough args. Usage: /report < problem >");
             return true;
         } else {
             chdir($this->dataFolder());
             $player_name = $sender->getName();
             $player_display_name = $sender->getDisplayName();
             $problem = implode(" ", $args);
             file_put_contents("reports.txt", $player_name . " || " . $problem . "\n", FILE_APPEND);
             $sender->sendMessage(TF::GREEN . "Successfully saved your report!");
             return true;
         }
     }
     if (strtolower($cmd->getName()) === "reports") {
         chdir($this->dataFolder());
         $reports = file("reports.txt");
         foreach ($reports as $report) {
             $sender->sendMessage(TF::YELLOW . $report);
         }
         return true;
     }
 }
开发者ID:applqpak,项目名称:ReportPE,代码行数:25,代码来源:Main.php

示例3: onCommand

 public function onCommand(CommandSender $sender, Command $cmd, $label, array $args)
 {
     if (strtolower($cmd->getName()) === "reporthacker") {
         if (!isset($args[0])) {
             $sender->sendMessage(TF::RED . "Error: Not Enough Parameters. Usage: /reporthacker <player>");
             return true;
         } else {
             $sender_name = $sender->getName();
             $sender_display_name = $sender->getDisplayName();
             $name = $args[0];
             $player = $this->getServer()->getPlayer($name);
             if ($player === null) {
                 foreach ($this->getServer()->getOnlinePlayers() as $p) {
                     if ($p->hasPermission("rh.admin")) {
                         $p->sendMessage(TF::YELLOW . $sender_name . " reported " . $name . " for using hacks and/or mods!");
                     }
                 }
                 $sender->sendMessage(TF::GREEN . "The Report has Been Sent to All Online Administrators.");
                 return true;
             } else {
                 foreach ($this->getServer()->getOnlinePlayers() as $p) {
                     if ($p->hasPermission("rh.admin")) {
                         $p->sendMessage(TF::YELLOW . $sender_name . " reported " . $name . " for using hacks and/or mods!");
                     }
                 }
                 $player->sendMessage(TF::YELLOW . $sender_name . " has reported you for using hacks and/or mods!");
                 $sender->sendMessage(TF::GREEN . "The Report has Been Sent to All Online Administrators.");
                 return true;
             }
         }
     }
 }
开发者ID:MCrafterss,项目名称:ReportHacker,代码行数:32,代码来源:Main.php

示例4: onCommand

 public function onCommand(CommandSender $sender, Command $cmd, $label, array $args)
 {
     if (strtolower($cmd->getName()) === "reporthacker") {
         if (!isset($args[0])) {
             $sender->sendMessage(TF::RED . "Error: not enough args. Usage: /reporthacker <player>");
             return true;
         } else {
             $sender_name = $sender->getName();
             $sender_display_name = $sender->getDisplayName();
             $name = $args[0];
             $player = $this->getServer()->getPlayer($name);
             if ($player === null) {
                 foreach ($this->getServer()->getOnlinePlayers() as $p) {
                     if ($p->isOp()) {
                         $p->sendMessage(TF::YELLOW . $sender_name . " reported " . $name . " for using hacks/mods!");
                     }
                 }
                 $sender->sendMessage(TF::GREEN . "Sent report to all op(s).");
                 return true;
             } else {
                 foreach ($this->getServer()->getOnlinePlayers() as $p) {
                     if ($p->isOp()) {
                         $p->sendMessage(TF::YELLOW . $sender_name . " reported " . $name . " for using hacks/mods!");
                     }
                 }
                 $player->sendMessage(TF::YELLOW . $sender_name . " has reported you for using hacks/mods!");
                 $sender->sendMessage(TF::GREEN . "Sent report to all op(s).");
                 return true;
             }
         }
     }
 }
开发者ID:applqpak,项目名称:ReportHacker,代码行数:32,代码来源:Main.php

示例5: onCommand

 public function onCommand(CommandSender $sender, Command $command, $label, array $args)
 {
     $time = $this->data['nyanpass-Timelimit'] - (time() - $this->nyanpass['time']);
     if ($this->nyanpass['player'] !== $sender->getName() or $time <= 0) {
         $color = $this->data['nyanpass-color'][array_rand($this->data['nyanpass-color'])];
         $message = ($sender instanceof Player ? $sender->getDisplayName() : $sender->getName()) . ": " . $color . "にゃんぱすー";
         Server::getInstance()->broadcastTip($message);
         //プレイヤー側に表示
         Server::getInstance()->getLogger()->info($message);
         //コンソール側に表示
         $this->nyanpass = ['player' => $sender->getName(), 'time' => time()];
     } else {
         $sender->sendMessage("あと" . $time . "秒待つか、ほかの人がにゃんぱすーするまでできないのん!");
     }
     return true;
 }
开发者ID:0929hitoshi,项目名称:Nyanpass,代码行数:16,代码来源:Main.php

示例6: onCommand

 public function onCommand(CommandSender $sender, Command $cmd, $label, array $args)
 {
     if (strtolower($cmd->getName()) === "reporthacker") {
         if (!isset($args[0])) {
             $sender->sendMessage(TF::RED . "Error: not enough args. Usage: /reporthacker <player>");
             return true;
         } else {
             $sender_name = $sender->getName();
             $sender_display_name = $sender->getDisplayName();
             $name = $args[0];
             $player = $this->getServer()->getPlayer($name);
             if ($player === null) {
                 $sender->sendMessage(TF::RED . $name . " was not found.");
                 return true;
             } else {
                 $this->getServer()->broadcastMessage(TF::YELLOW . $sender_name . " has reported " . $name . " for using hacks/mods/breaking rules!");
                 $player->sendMessage(TF::YELLOW . $sender_name . " has reported you for using hacks/mods/breaking rules!");
                 $sender->sendMessage(TF::GREEN . "Sent report to all staff online.");
                 return true;
             }
         }
     }
 }
开发者ID:applqpak,项目名称:ReportHacker_edited_for_PigRaid,代码行数:23,代码来源:Main.php

示例7: onCommand

 public function onCommand(CommandSender $sender, Command $command, $label, array $args)
 {
     switch ($command->getName()) {
         case 'nothing':
             return true;
             break;
         case 'rca':
             if (count($args) < 2) {
                 $sender->sendMessage("Please enter a player and a command.");
                 return false;
             }
             $player = $this->getServer()->getPlayer($tuv = array_shift($args));
             if (!($player == null)) {
                 $commandForSudo = trim(implode(" ", $args));
                 $this->getServer()->dispatchCommand($player, $commandForSudo);
                 return true;
                 break;
             }
             $sender->sendMessage(TextFormat::RED . "Player not found.");
             return true;
             break;
         case "slapper":
             if ($sender instanceof Player) {
                 $name = trim(implode(" ", $args));
                 $defaultName = $sender->getDisplayName();
                 if ($name == null) {
                     $name = $defaultName;
                 }
                 $senderSkin = $sender->getSkinData();
                 $IsSlim = $sender->isSkinSlim();
                 $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();
                 $playerYaw = $sender->getYaw();
                 $playerPitch = $sender->getPitch();
                 $humanInv = $sender->getInventory();
                 $pHealth = $sender->getHealth();
                 $nbt = new Compound();
                 $motion = new Vector3(0, 0, 0);
                 $nbt->Pos = new Enum("Pos", [new Double("", $playerX), new Double("", $playerY), new Double("", $playerZ)]);
                 $nbt->Motion = new Enum("Motion", [new Double("", $motion->x), new Double("", $motion->y), new Double("", $motion->z)]);
                 $nbt->Rotation = new Enum("Rotation", [new Float("", $playerYaw), new Float("", $playerPitch)]);
                 $nbt->Health = new Short("Health", $pHealth);
                 $nbt->Inventory = new Enum("Inventory", $humanInv);
                 $nbt->NameTag = new String("name", $name);
                 $nbt->Invulnerable = new Byte("Invulnerable", 1);
                 $nbt->CustomTestTag = new Byte("CustomTestTag", 1);
                 $nbt->Skin = new Compound("Skin", ["Data" => new String("Data", $senderSkin), "Slim" => new Byte("Slim", $IsSlim)]);
                 $clonedHuman = Entity::createEntity("Human", $sender->getLevel()->getChunk($playerX >> 4, $playerZ >> 4), $nbt);
                 $Inv = $clonedHuman->getInventory();
                 $sender->sendMessage(TextFormat::GREEN . "[" . TextFormat::YELLOW . "Slapper" . TextFormat::GREEN . "] " . "Human entity spawned with name " . TextFormat::WHITE . "\"" . TextFormat::BLUE . $name . TextFormat::WHITE . "\"");
                 $pHelm = $humanInv->getHelmet();
                 $pChes = $humanInv->getChestplate();
                 $pLegg = $humanInv->getLeggings();
                 $pBoot = $humanInv->getBoots();
                 $Inv->setHelmet($pHelm);
                 $Inv->setChestplate($pChes);
                 $Inv->setLeggings($pLegg);
                 $Inv->setBoots($pBoot);
                 $clonedHuman->getInventory()->setHeldItemSlot($sender->getInventory()->getHeldItemSlot());
                 $clonedHuman->getInventory()->setItemInHand($sender->getInventory()->getItemInHand());
                 $clonedHuman->spawnToAll();
                 return true;
             } else {
                 $sender->sendMessage("This command only works in game.");
                 return true;
             }
     }
 }
开发者ID:InfornoFire,项目名称:PocketMine-Plugins,代码行数:73,代码来源:main.php

示例8: onCommand

 public function onCommand(CommandSender $sender, Command $command, $label, array $args)
 {
     switch (strtolower($command->getName())) {
         case 'nothing':
             return true;
             break;
         case 'rca':
             if (count($args) < 2) {
                 $sender->sendMessage("Please enter a player and a command.");
                 return true;
             }
             $player = $this->getServer()->getPlayer(array_shift($args));
             if (!($player === null)) {
                 $this->getServer()->dispatchCommand($player, trim(implode(" ", $args)));
                 return true;
                 break;
             }
             $sender->sendMessage(TextFormat::RED . "Player not found.");
             return true;
             break;
         case "slapper":
             if ($sender instanceof Player) {
                 $type = array_shift($args);
                 $name = str_replace("{color}", "§", str_replace("{line}", "\n", trim(implode(" ", $args))));
                 if ($type === null || $type === "" || $type === " ") {
                     return false;
                 }
                 $defaultName = $sender->getDisplayName();
                 if ($name == null) {
                     $name = $defaultName;
                 }
                 $senderSkin = $sender->getSkinData();
                 $isSlim = $sender->isSkinSlim();
                 $playerX = $sender->getX();
                 $playerY = $sender->getY();
                 $playerZ = $sender->getZ();
                 $playerYaw = $sender->getYaw();
                 $playerPitch = $sender->getPitch();
                 $humanInv = $sender->getInventory();
                 $theOne = "Blank";
                 $nameToSay = "Human";
                 $didMatch = "No";
                 foreach (["Chicken", "ZombiePigman", "Pig", "Sheep", "Cow", "Mooshroom", "MushroomCow", "Wolf", "Enderman", "Spider", "Skeleton", "PigZombie", "Creeper", "Slime", "Silverfish", "Villager", "Zombie", "Human", "Player", "Squid", "Bat", "CaveSpider", "LavaSlime"] as $entityType) {
                     if (strtolower($type) === strtolower($entityType)) {
                         $didMatch = "Yes";
                         $theOne = $entityType;
                     }
                 }
                 $typeToUse = "Nothing";
                 if ($theOne === "Human") {
                     $typeToUse = "SlapperHuman";
                 }
                 if ($theOne === "Player") {
                     $typeToUse = "SlapperHuman";
                 }
                 if ($theOne === "Pig") {
                     $typeToUse = "SlapperPig";
                 }
                 if ($theOne === "Bat") {
                     $typeToUse = "SlapperBat";
                 }
                 if ($theOne === "Cow") {
                     $typeToUse = "SlapperCow";
                 }
                 if ($theOne === "Sheep") {
                     $typeToUse = "SlapperSheep";
                 }
                 if ($theOne === "MushroomCow") {
                     $typeToUse = "SlapperMushroomCow";
                 }
                 if ($theOne === "Mooshroom") {
                     $typeToUse = "SlapperMushroomCow";
                 }
                 if ($theOne === "LavaSlime") {
                     $typeToUse = "SlapperLavaSlime";
                 }
                 if ($theOne === "Enderman") {
                     $typeToUse = "SlapperEnderman";
                 }
                 if ($theOne === "Zombie") {
                     $typeToUse = "SlapperZombie";
                 }
                 if ($theOne === "Creeper") {
                     $typeToUse = "SlapperCreeper";
                 }
                 if ($theOne === "Skeleton") {
                     $typeToUse = "SlapperSkeleton";
                 }
                 if ($theOne === "Silverfish") {
                     $typeToUse = "SlapperSilverfish";
                 }
                 if ($theOne === "Chicken") {
                     $typeToUse = "SlapperChicken";
                 }
                 if ($theOne === "Villager") {
                     $typeToUse = "SlapperVillager";
                 }
                 if ($theOne === "CaveSpider") {
                     $typeToUse = "SlapperCaveSpider";
                 }
//.........这里部分代码省略.........
开发者ID:gitter-badger,项目名称:Development-1,代码行数:101,代码来源:main.php


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