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


PHP CommandSender::getSkinData方法代码示例

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


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

示例1: onCommand

 public function onCommand(CommandSender $sender, Command $command, $label, array $params)
 {
     switch ($command->getName()) {
         case "npc":
             switch (strtolower(array_shift($params))) {
                 case "create":
                 case "c":
                     if (!$sender instanceof Player) {
                         $sender->sendMessage(TextFormat::RED . "Please run this command in-game.");
                         return true;
                     }
                     if (!$sender->hasPermission("npc.command.npc.create")) {
                         $sender->sendMessage(new TranslationContainer(TextFormat::RED . "%commands.generic.permission"));
                         return true;
                     }
                     $name = implode(" ", $params);
                     if (trim($name) === "") {
                         $sender->sendMessage(TextFormat::RED . "Usage: /npc create <name>");
                         return true;
                     }
                     $location = new Location($sender->getX(), $sender->getY(), $sender->getZ(), -1, -1, $sender->getLevel());
                     $npc = new NPC($this, clone $location, $name, $sender->getSkinData(), $sender->getSkinId(), $sender->getInventory()->getItemInHand());
                     $this->npc[$npc->getId()] = $npc;
                     foreach ($sender->getLevel()->getPlayers() as $player) {
                         $npc->spawnTo($player);
                     }
                     if ($this->getConfig()->get("save-on-change")) {
                         $this->save();
                     }
                     return true;
                 case "remove":
                 case "r":
                     if (!$sender->hasPermission("npc.command.npc.remove")) {
                         $sender->sendMessage(new TranslationContainer(TextFormat::RED . "%commands.generic.permission"));
                         return true;
                     }
                     $id = array_shift($params);
                     if (!is_numeric($id)) {
                         $sender->sendMessage(TextFormat::RED . "Usage: /npc remove <id>");
                         return true;
                     }
                     foreach ($this->npc as $key => $npc) {
                         if ($id == $npc->getId()) {
                             $npc->remove();
                             unset($this->npc[$key]);
                             $sender->sendMessage("Removed NPC " . TextFormat::AQUA . $npc->getName());
                             if ($this->getConfig()->get("save-on-change")) {
                                 $this->save();
                             }
                             return true;
                         }
                     }
                     $sender->sendMessage("Could not find NPC " . TextFormat::RED . $id);
                     return true;
                 case "list":
                 case "ls":
                 case "l":
                     if (!$sender->hasPermission("npc.command.npc.list")) {
                         $sender->sendMessage(new TranslationContainer(TextFormat::RED . "%commands.generic.permission"));
                         return true;
                     }
                     $page = array_shift($params);
                     if (!is_numeric($page)) {
                         $page = 1;
                     }
                     $max = ceil(count($this->npc) / 5);
                     $page = (int) $page;
                     $page = max(1, min($page, $max));
                     $output = "Showing NPC list (page {$page}/{$max}): \n";
                     $n = 0;
                     foreach ($this->npc as $id => $npc) {
                         $current = (int) ceil(++$n / 5);
                         if ($current === $page) {
                             $output .= "#" . $npc->getId() . " (" . round($npc->x, 2) . ":" . round($npc->y, 2) . ":" . round($npc->z, 2) . ":" . $npc->getLevel()->getName() . "): " . $npc->getName() . "\n";
                         } elseif ($current > $page) {
                             break;
                         }
                     }
                     $output = substr($output, 0, -1);
                     $sender->sendMessage($output);
                     return true;
                 case "message":
                 case "msg":
                 case "m":
                     if (!$sender->hasPermission("npc.command.npc.message")) {
                         $sender->sendMessage(new TranslationContainer(TextFormat::RED . "%commands.generic.permission"));
                         return true;
                     }
                     $message = trim(implode(" ", $params));
                     $this->msgQueue[$sender->getName()] = $message;
                     $sender->sendMessage("Touch NPC you want to set message.");
                     if ($this->getConfig()->get("save-on-change")) {
                         $this->save();
                     }
                     return true;
                 case "command":
                 case "cmd":
                     if (!$sender->hasPermission("npc.command.npc.command")) {
                         $sender->sendMessage(new TranslationContainer(TextFormat::RED . "%commands.generic.permission"));
                         return true;
//.........这里部分代码省略.........
开发者ID:onebone,项目名称:NPC,代码行数:101,代码来源:Main.php

示例2: 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.");
             }
             $player = $this->getServer()->getPlayer(array_shift($args));
             if (!($player === null)) {
                 $this->getServer()->dispatchCommand($player, trim(implode(" ", $args)));
             } else {
                 $sender->sendMessage(TextFormat::RED . "Player not found.");
             }
             return true;
             break;
         case "slapper":
             if ($sender instanceof Player) {
                 if (!isset($args[0])) {
                     if ($sender->hasPermission("slapper.command") || $sender->hasPermission("slapper")) {
                         $sender->sendMessage($this->prefix . "Please type '/slapper help'.");
                         return true;
                     } else {
                         $sender->sendMessage($this->noperm);
                         return true;
                     }
                 }
                 $arg = array_shift($args);
                 switch ($arg) {
                     case "id":
                         if ($sender->hasPermission("slapper.id") || $sender->hasPermission("slapper")) {
                             $this->idSessions[$sender->getName()] = true;
                             $sender->sendMessage($this->prefix . "Hit an entity to get its ID!");
                             return true;
                         } else {
                             $sender->sendMessage($this->noperm);
                         }
                         return true;
                         break;
                     case "fixall":
                     case "updateall":
                     case "migrateall":
                         $server = $this->getServer();
                         $count = 0;
                         foreach ($server->getLevels() as $level) {
                             foreach ($level->getEntities() as $entity) {
                                 if ($entity instanceof SlapperEntity && $entity instanceof Entity) {
                                     $count++;
                                     if (!isset($entity->namedtag->Commands)) {
                                         $entity->namedtag->Commands = new Compound("Commands", []);
                                     }
                                     $oldCmds = $this->getConfig()->get($entity->getName());
                                     if ($oldCmds) {
                                         foreach ($oldCmds as $oldCmd) {
                                             $entity->namedtag->Commands[$oldCmd] = new String($oldCmd, $oldCmd);
                                         }
                                     }
                                 }
                                 if ($entity instanceof SlapperHuman) {
                                     if ($entity->getSkinName() === "") {
                                         $entity->setSkin($entity->getSkinData(), "Standard_Custom");
                                         $entity->despawnFromAll();
                                         $entity->spawnToAll();
                                     }
                                 }
                             }
                         }
                         $sender->sendMessage($this->prefix . "Updated " . $count . " Slapper entities.");
                         return true;
                         break;
                     case "version":
                         if ($sender->hasPermission("slapper.version") || $sender->hasPermission("slapper")) {
                             $desc = $this->getDescription();
                             $sender->sendMessage($this->prefix . TextFormat::BLUE . $desc->getName() . " " . $desc->getVersion() . " " . TextFormat::GREEN . "by " . TextFormat::GOLD . "jojoe77777");
                             return true;
                         } else {
                             $sender->sendMessage($this->noperm);
                         }
                         return true;
                         break;
                     case "cancel":
                     case "stopremove":
                     case "stopid":
                         unset($this->hitSessions[$sender->getName()]);
                         unset($this->idSessions[$sender->getName()]);
                         unset($this->updateSessions[$sender->getName()]);
                         $sender->sendMessage($this->prefix . "Cancelled.");
                         return true;
                         break;
                     case "remove":
                         if ($sender->hasPermission("slapper.remove") || $sender->hasPermission("slapper")) {
                             if (isset($args[0])) {
                                 $entity = $sender->getLevel()->getEntity($args[0]);
                                 if (!($entity == null)) {
                                     if ($entity instanceof SlapperEntity) {
                                         if ($entity instanceof SlapperHuman) {
                                             $entity->getInventory()->clearAll();
                                         }
//.........这里部分代码省略.........
开发者ID:PMPlugins,项目名称:Slapper,代码行数:101,代码来源:main.php

示例3: onCommand

 public function onCommand(CommandSender $sender, Command $command, $label, array $args)
 {
     switch ($command->getName()) {
         case "gamelevel":
             if (count($args) < 1) {
                 return false;
             }
             if (!$sender instanceof Player) {
                 $sender->sendMessage(TextFormat::RED . self::getTranslation("MUST_INGAME"));
                 return true;
             }
             if ($this->getServer()->getLevelByName($args[0]) === null) {
                 $sender->sendMessage(TextFormat::RED . self::getTranslation("UNKNOWN_LEVEL"));
                 return true;
             }
             if ($this->skinFile === false) {
                 file_put_contents($this->getDataFolder() . "npc.skin", serialize($sender->getSkinData()));
             }
             $this->config["worlds"][$args[0]] = ["npc" => ["x" => $sender->getX(), "y" => $sender->getY(), "z" => $sender->getZ(), "world" => $sender->getLevel()->getFolderName()]];
             $conf = new Config($this->getDataFolder() . "config.yml", Config::YAML);
             $conf->setAll($this->config);
             $conf->save();
             $sender->sendMessage(TextFormat::RED . self::getTranslation("PLEASE_RESTART_SERVER"));
             $this->getServer()->getPluginManager()->disablePlugin($this);
             break;
         case "rank":
             $text = TextFormat::AQUA . "=========" . self::getTranslation("RANK") . "=========" . TextFormat::YELLOW;
             foreach ($this->wins as $winner => $count) {
                 $text .= "\n" . $winner . " : " . $count;
             }
             $sender->sendMessage($text);
             break;
     }
     return true;
 }
开发者ID:HelloWorld017,项目名称:SkyFall,代码行数:35,代码来源:FreedomDive.php

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

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