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


PHP CommandSender::getSkinName方法代码示例

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


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

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

示例2: 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->hasPermission("npc.command.npc.create")) {
                         $sender->sendMessage(TextFormat::RED . "You don't have permission to use this command.");
                         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(clone $location, $name, $sender->getSkinData(), $sender->getSkinName(), $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(TextFormat::RED . "You don't have permission to use this command.");
                         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(TextFormat::RED . "You don't have permission to use this command.");
                         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(TextFormat::RED . "You don't have permission to use this command.");
                         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;
             }
     }
     return false;
 }
开发者ID:wodnr0804,项目名称:NPC,代码行数:95,代码来源:Main.php


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