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


PHP CommandSender::getSkinId方法代码示例

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


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


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