Пример #1
0
 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;
             }
     }
 }
Пример #2
0
 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) {
                 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);
                         }
                         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);
                         }
                         break;
                     case "cancel":
                     case "stopremove":
                     case "stopid":
                         unset($this->hitSessions[$sender->getName()]);
                         unset($this->idSessions[$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 SlapperHuman || $entity instanceof SlapperSheep || $entity instanceof SlapperPigZombie || $entity instanceof SlapperVillager || $entity instanceof SlapperCaveSpider || $entity instanceof SlapperZombie || $entity instanceof SlapperChicken || $entity instanceof SlapperSpider || $entity instanceof SlapperSilverfish || $entity instanceof SlapperPig || $entity instanceof SlapperCow || $entity instanceof SlapperSlime || $entity instanceof SlapperLavaSlime || $entity instanceof SlapperEnderman || $entity instanceof SlapperMushroomCow || $entity instanceof SlapperBat || $entity instanceof SlapperCreeper || $entity instanceof SlapperSkeleton || $entity instanceof SlapperSquid || $entity instanceof SlapperWolf || $entity instanceof SlapperGhast || $entity instanceof SlapperZombieVillager || $entity instanceof SlapperBlaze || $entity instanceof SlapperOcelot || $entity instanceof SlapperIronGolem || $entity instanceof SlapperSnowman || $entity instanceof SlapperBoat || $entity instanceof SlapperPrimedTNT || $entity instanceof SlapperFallingSand || $entity instanceof SlapperMinecart) {
                                         if ($entity instanceof SlapperHuman) {
                                             $entity->getInventory()->clearAll();
                                         }
                                         $entity->kill();
                                         $sender->sendMessage($this->prefix . "Entity removed.");
                                     } else {
                                         $sender->sendMessage($this->prefix . "That entity is not handled by Slapper.");
                                     }
                                 } else {
                                     $sender->sendMessage($this->prefix . "Entity does not exist.");
                                 }
                                 return true;
                             }
                             $this->hitSessions[$sender->getName()] = true;
                             $sender->sendMessage($this->prefix . "Hit an entity to remove it.");
                         } else {
                             $sender->sendMessage($this->noperm);
                         }
                         break;
                     case "edit":
                         if ($sender->hasPermission("slapper.edit") || $sender->hasPermission("slapper")) {
                             if (isset($args[0])) {
                                 $entity = $sender->getLevel()->getEntity($args[0]);
                                 if (!($entity == null)) {
                                     if ($entity instanceof SlapperHuman || $entity instanceof SlapperSheep || $entity instanceof SlapperPigZombie || $entity instanceof SlapperVillager || $entity instanceof SlapperCaveSpider || $entity instanceof SlapperZombie || $entity instanceof SlapperChicken || $entity instanceof SlapperSpider || $entity instanceof SlapperSilverfish || $entity instanceof SlapperPig || $entity instanceof SlapperCow || $entity instanceof SlapperSlime || $entity instanceof SlapperLavaSlime || $entity instanceof SlapperEnderman || $entity instanceof SlapperMushroomCow || $entity instanceof SlapperBat || $entity instanceof SlapperCreeper || $entity instanceof SlapperSkeleton || $entity instanceof SlapperSquid || $entity instanceof SlapperWolf || $entity instanceof SlapperGhast || $entity instanceof SlapperZombieVillager || $entity instanceof SlapperBlaze || $entity instanceof SlapperOcelot || $entity instanceof SlapperIronGolem || $entity instanceof SlapperSnowman || $entity instanceof SlapperMinecart || $entity instanceof SlapperBoat || $entity instanceof SlapperFallingSand || $entity instanceof SlapperPrimedTNT) {
                                         if (isset($args[1])) {
                                             switch ($args[1]) {
                                                 case "helm":
                                                 case "helmet":
                                                 case "head":
                                                 case "hat":
                                                 case "cap":
                                                     if ($entity instanceof SlapperHuman) {
                                                         if (isset($args[2])) {
                                                             $entity->getInventory()->setHelmet(Item::fromString($args[2]));
                                                             $sender->sendMessage($this->prefix . "Helmet updated.");
                                                         } else {
                                                             $sender->sendMessage($this->prefix . "Please enter an item ID.");
                                                         }
                                                     } else {
                                                         $sender->sendMessage($this->prefix . "That entity can not wear armor.");
                                                     }
                                                     return true;
                                                 case "chest":
                                                 case "shirt":
                                                 case "chestplate":
                                                     if ($entity instanceof SlapperHuman) {
                                                         if (isset($args[2])) {
                                                             $entity->getInventory()->setChestplate(Item::fromString($args[2]));
                                                             $sender->sendMessage($this->prefix . "Chestplate updated.");
                                                         } else {
                                                             $sender->sendMessage($this->prefix . "Please enter an item ID.");
                                                         }
                                                     } else {
                                                         $sender->sendMessage($this->prefix . "That entity can not wear armor.");
                                                     }
                                                     return true;
                                                 case "pants":
                                                 case "legs":
                                                 case "leggings":
                                                     if ($entity instanceof SlapperHuman) {
                                                         if (isset($args[2])) {
                                                             $entity->getInventory()->setLeggings(Item::fromString($args[2]));
                                                             $sender->sendMessage($this->prefix . "Leggings updated.");
                                                         } else {
                                                             $sender->sendMessage($this->prefix . "Please enter an item ID.");
                                                         }
                                                     } else {
                                                         $sender->sendMessage($this->prefix . "That entity can not wear armor.");
                                                     }
                                                     return true;
                                                 case "feet":
                                                 case "boots":
                                                 case "shoes":
                                                     if ($entity instanceof SlapperHuman) {
                                                         if (isset($args[2])) {
                                                             $entity->getInventory()->setBoots(Item::fromString($args[2]));
                                                             $sender->sendMessage($this->prefix . "Boots updated.");
                                                         } else {
                                                             $sender->sendMessage($this->prefix . "Please enter an item ID.");
                                                         }
                                                     } else {
                                                         $sender->sendMessage($this->prefix . "That entity can not wear armor.");
                                                     }
                                                     return true;
                                                 case "hand":
                                                 case "item":
                                                 case "holding":
                                                 case "arm":
                                                 case "held":
                                                     if ($entity instanceof SlapperHuman) {
                                                         if (isset($args[2])) {
                                                             $entity->getInventory()->setItemInHand(Item::fromString($args[2]));
                                                             $sender->sendMessage($this->prefix . "Item updated.");
                                                         } else {
                                                             $sender->sendMessage($this->prefix . "Please enter an item ID.");
                                                         }
                                                     } else {
                                                         $sender->sendMessage($this->prefix . "That entity can not wear armor.");
                                                     }
                                                     return true;
                                                 case "skin":
                                                     if ($entity instanceof SlapperHuman) {
                                                         $entity->setSkin($sender->getSkinData(), $sender->isSkinSlim());
                                                         $entity->spawnToAll();
                                                         $sender->sendMessage($this->prefix . "Skin updated.");
                                                     } else {
                                                         $sender->sendMessage($this->prefix . "That entity can't have a skin.");
                                                     }
                                                     return true;
                                                 case "name":
                                                 case "customname":
                                                     if (isset($args[2])) {
                                                         array_shift($args);
                                                         array_shift($args);
                                                         $entity->setDataProperty(2, Entity::DATA_TYPE_STRING, trim(implode(" ", $args)));
                                                         $sender->sendMessage($this->prefix . "Name updated.");
                                                     } else {
                                                         $sender->sendMessage($this->prefix . "Please enter a name.");
                                                     }
                                                     return true;
                                                 case "namevisible":
                                                 case "customnamevisible":
                                                 case "tagvisible":
                                                 case "name_visible":
                                                 case "custom_name_visible":
                                                 case "tag_visible":
                                                     if (isset($args[2])) {
                                                         $entity->setDataProperty(3, 0, intval($args[2]));
                                                         $entity->despawnFromAll();
                                                         $entity->spawnToAll();
                                                         $sender->sendMessage($this->prefix . "Name visibility updated.");
                                                     } else {
                                                         $sender->sendMessage($this->prefix . "Please enter a value, 1 or 0.");
                                                     }
                                                     return true;
                                                 case "addc":
                                                 case "addcmd":
                                                 case "addcommand":
                                                     if (isset($args[2])) {
                                                         array_shift($args);
                                                         array_shift($args);
                                                         $input = trim(implode(" ", $args));
                                                         $entity->namedtag->Commands[$input] = new String($input, $input);
                                                         $sender->sendMessage($this->prefix . "Command added.");
                                                     } else {
                                                         $sender->sendMessage($this->prefix . "Please enter a command.");
                                                     }
                                                     return true;
                                                 case "delc":
                                                 case "delcmd":
                                                 case "removecommand":
                                                     if (isset($args[2])) {
                                                         array_shift($args);
                                                         array_shift($args);
                                                         $input = trim(implode(" ", $args));
                                                         unset($entity->namedtag->Commands[$input]);
                                                         $sender->sendMessage($this->prefix . "Command removed.");
                                                     } else {
                                                         $sender->sendMessage($this->prefix . "Please enter a command.");
                                                     }
                                                     return true;
                                                 case "listcommands":
                                                 case "listcmds":
                                                 case "listcs":
                                                     if (isset($entity->namedtag->Commands)) {
                                                         foreach ($entity->namedtag->Commands as $cmd) {
                                                             $sender->sendMessage(TextFormat::GREEN . "[" . TextFormat::YELLOW . "S" . TextFormat::GREEN . "] " . "{$cmd}\n");
                                                         }
                                                     } else {
                                                         $sender->sendMessage($this->prefix . "That entity does not have any commands.");
                                                     }
                                                     return true;
                                                 case "update":
                                                 case "fix":
                                                 case "migrate":
                                                     if ($this->getConfig()->get($entity->getName()) !== false) {
                                                         foreach ($this->getConfig()->get($entity->getName()) as $cmd) {
                                                             $entity->namedtag->Commands[$cmd] = new String($cmd, $cmd);
                                                         }
                                                         $sender->sendMessage($this->prefix . "Commands migrated.");
                                                     } else {
                                                         $sender->sendMessage($this->prefix . "No old commands found.");
                                                     }
                                                     return true;
                                                 case "block":
                                                 case "tile":
                                                 case "blockid":
                                                 case "tileid":
                                                     if ($entity instanceof SlapperFallingSand) {
                                                         $entity->namedtag->BlockID = new Int("BlockID", intval($args[2]));
                                                         $entity->spawnToAll();
                                                         $sender->sendMessage($this->prefix . "Block updated.");
                                                     } else {
                                                         $sender->sendMessage($this->prefix . "That entity is not a block.");
                                                     }
                                                     return true;
                                                     break;
                                                 case "teleporthere":
                                                 case "tphere":
                                                 case "movehere":
                                                 case "bringhere":
                                                     $entity->teleport($sender);
                                                     $sender->sendMessage($this->prefix . "Teleported entity to you.");
                                                     $entity->despawnFromAll();
                                                     $entity->spawnToAll();
                                                     return true;
                                                     break;
                                                 case "teleportto":
                                                 case "tpto":
                                                 case "goto":
                                                 case "teleport":
                                                 case "tp":
                                                     $sender->teleport($entity);
                                                     $sender->sendMessage($this->prefix . "Teleported you to entity.");
                                                     return true;
                                                     break;
                                                 default:
                                                     $sender->sendMessage($this->prefix . "Unknown command.");
                                                     return true;
                                             }
                                         } else {
                                             $sender->sendMessage($this->helpHeader);
                                             foreach ($this->editArgs as $msgArg) {
                                                 $sender->sendMessage(str_ireplace("<eid>", $args[0], TextFormat::GREEN . " - " . $msgArg . "\n"));
                                             }
                                             return true;
                                         }
                                     } else {
                                         $sender->sendMessage($this->prefix . "That entity is not handled by Slapper.");
                                     }
                                 } else {
                                     $sender->sendMessage($this->prefix . "Entity does not exist.");
                                 }
                                 return true;
                             } else {
                                 $sender->sendMessage($this->helpHeader);
                                 foreach ($this->editArgs as $msgArg) {
                                     $sender->sendMessage(TextFormat::GREEN . " - " . $msgArg . "\n");
                                 }
                                 return true;
                             }
                             $this->hitSessions[$sender->getName()] = true;
                             $sender->sendMessage($this->prefix . "Hit an entity to remove it.");
                         } else {
                             $sender->sendMessage($this->prefix . "You don't have permission.");
                         }
                         return true;
                         break;
                     case "help":
                     case "?":
                         $sender->sendMessage($this->helpHeader);
                         foreach ($this->mainArgs as $msgArg) {
                             $sender->sendMessage(TextFormat::GREEN . " - " . $msgArg . "\n");
                         }
                         return true;
                         break;
                     case "add":
                     case "make":
                     case "create":
                     case "spawn":
                         $type = array_shift($args);
                         $spawn = true;
                         $name = str_replace("{color}", "§", str_replace("{line}", "\n", trim(implode(" ", $args))));
                         if ($type === null || $type === "" || $type === " ") {
                             $sender->sendMessage($this->prefix . "Please enter an entity type.");
                             return true;
                         }
                         $defaultName = $sender->getDisplayName();
                         if ($name == null) {
                             $name = $defaultName;
                         }
                         $playerX = $sender->getX();
                         $playerY = $sender->getY();
                         $playerZ = $sender->getZ();
                         $inventory = $sender->getInventory();
                         $theOne = "Blank";
                         foreach (["Chicken", "ZombiePigman", "Pig", "Sheep", "Cow", "Mooshroom", "MushroomCow", "Wolf", "Enderman", "Spider", "Skeleton", "PigZombie", "Creeper", "Slime", "Silverfish", "Villager", "Zombie", "Human", "Player", "Squid", "Bat", "CaveSpider", "LavaSlime", "Ghast", "Ocelot", "Blaze", "ZombieVillager", "VillagerZombie", "Snowman", "SnowGolem", "Minecart", "FallingSand", "FallingBlock", "FakeBlock", "Boat", "PrimedTNT"] as $entityType) {
                             if (strtolower($type) === strtolower($entityType)) {
                                 $theOne = $entityType;
                             }
                         }
                         $typeToUse = "Nothing";
                         switch ($theOne) {
                             case "Human":
                                 $typeToUse = "SlapperHuman";
                                 break;
                             case "Player":
                                 $typeToUse = "SlapperHuman";
                                 break;
                             case "Pig":
                                 $typeToUse = "SlapperPig";
                                 break;
                             case "Bat":
                                 $typeToUse = "SlapperBat";
                                 break;
                             case "Cow":
                                 $typeToUse = "SlapperCow";
                                 break;
                             case "Sheep":
                                 $typeToUse = "SlapperSheep";
                                 break;
                             case "MushroomCow":
                                 $typeToUse = "SlapperMushroomCow";
                                 break;
                             case "Mooshroom":
                                 $typeToUse = "SlapperMushroomCow";
                                 break;
                             case "LavaSlime":
                                 $typeToUse = "SlapperLavaSlime";
                                 break;
                             case "Enderman":
                                 $typeToUse = "SlapperEnderman";
                                 break;
                             case "Zombie":
                                 $typeToUse = "SlapperZombie";
                                 break;
                             case "Creeper":
                                 $typeToUse = "SlapperCreeper";
                                 break;
                             case "Skeleton":
                                 $typeToUse = "SlapperSkeleton";
                                 break;
                             case "Silverfish":
                                 $typeToUse = "SlapperSilverfish";
                                 break;
                             case "Chicken":
                                 $typeToUse = "SlapperChicken";
                                 break;
                             case "Villager":
                                 $typeToUse = "SlapperVillager";
                                 break;
                             case "CaveSpider":
                                 $typeToUse = "SlapperCaveSpider";
                                 break;
                             case "Spider":
                                 $typeToUse = "SlapperSpider";
                                 break;
                             case "Squid":
                                 $typeToUse = "SlapperSquid";
                                 break;
                             case "Wolf":
                                 $typeToUse = "SlapperWolf";
                                 break;
                             case "Slime":
                                 $typeToUse = "SlapperSlime";
                                 break;
                             case "PigZombie":
                                 $typeToUse = "SlapperPigZombie";
                                 break;
                             case "MagmaCube":
                                 $typeToUse = "SlapperLavaSlime";
                                 break;
                             case "ZombiePigman":
                                 $typeToUse = "SlapperPigZombie";
                                 break;
                             case "PrimedTNT":
                                 $typeToUse = "SlapperPrimedTNT";
                                 break;
                             case "Minecart":
                                 $typeToUse = "SlapperMinecart";
                                 break;
                             case "Boat":
                                 $typeToUse = "SlapperBoat";
                                 break;
                             case "FallingSand":
                                 $typeToUse = "SlapperFallingSand";
                                 break;
                             case "FallingBlock":
                                 $typeToUse = "SlapperFallingSand";
                                 break;
                             case "FakeBlock":
                                 $typeToUse = "SlapperFallingSand";
                                 break;
                         }
                         /*0.12 mobs*/
                         if ($this->supports_0_12) {
                             switch ($theOne) {
                                 case "ZombieVillager":
                                     $typeToUse = "SlapperZombieVillager";
                                     break;
                                 case "VillagerZombie":
                                     $typeToUse = "SlapperZombieVillager";
                                     break;
                                 case "Ghast":
                                     $typeToUse = "SlapperGhast";
                                     break;
                                 case "Blaze":
                                     $typeToUse = "SlapperBlaze";
                                     break;
                                 case "IronGolem":
                                     $typeToUse = "SlapperIronGolem";
                                     break;
                                 case "VillagerGolem":
                                     $typeToUse = "SlapperIronGolem";
                                     break;
                                 case "SnowGolem":
                                     $typeToUse = "SlapperSnowman";
                                     break;
                                 case "Snowman":
                                     $typeToUse = "SlapperSnowman";
                                     break;
                                 case "Ocelot":
                                     $typeToUse = "SlapperOcelot";
                                     break;
                             }
                         }
                         if (!($typeToUse === "Nothing") && !($theOne === "Blank")) {
                             $nbt = $this->makeNBT($sender->getSkinData(), $sender->isSkinSlim(), $name, $inventory, $sender->getYaw(), $sender->getPitch(), $playerX, $playerY, $playerZ);
                             $slapperEntity = Entity::createEntity($typeToUse, $sender->getLevel()->getChunk($playerX >> 4, $playerZ >> 4), $nbt);
                             $sender->sendMessage($this->prefix . $theOne . " entity spawned with name " . TextFormat::WHITE . "\"" . TextFormat::BLUE . $name . TextFormat::WHITE . "\"");
                         }
                         if ($typeToUse === "SlapperHuman") {
                             $Inv = $slapperEntity->getInventory();
                             $Inv->setHelmet($inventory->getHelmet());
                             $Inv->setChestplate($inventory->getChestplate());
                             $Inv->setLeggings($inventory->getLeggings());
                             $Inv->setBoots($inventory->getBoots());
                             $slapperEntity->getInventory()->setHeldItemSlot($inventory->getHeldItemSlot());
                             $slapperEntity->getInventory()->setItemInHand($inventory->getItemInHand());
                         }
                         if (!($theOne == "Blank")) {
                             $slapperEntity->spawnToAll();
                         }
                         if ($typeToUse === "Nothing" || $theOne === "Blank") {
                             if ($spawn) {
                                 $sender->sendMessage($this->prefix . "Invalid entity.");
                             }
                         }
                         return true;
                     default:
                         $sender->sendMessage($this->prefix . "Unknown command. Type '/slapper help' for help.");
                         return true;
                 }
             } else {
                 $sender->sendMessage($this->prefix . "This command only works in game.");
                 return true;
             }
     }
 }
Пример #3
0
 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";
                 }
                 if ($theOne === "Spider") {
                     $typeToUse = "SlapperSpider";
                 }
                 if ($theOne === "Squid") {
                     $typeToUse = "SlapperSquid";
                 }
                 if ($theOne === "Wolf") {
                     $typeToUse = "SlapperWolf";
                 }
                 if ($theOne === "Slime") {
                     $typeToUse = "SlapperSlime";
                 }
                 if ($theOne === "PigZombie") {
                     $typeToUse = "SlapperPigZombie";
                 }
                 if ($theOne === "MagmaCube") {
                     $typeToUse = "SlapperLavaSlime";
                 }
                 if ($theOne === "ZombiePigman") {
                     $typeToUse = "SlapperPigZombie";
                 }
                 if ($theOne === "PigZombie") {
                     $typeToUse = "SlapperPigZombie";
                 }
                 if (strtolower($theOne) === "remove") {
                     if ($sender->hasPermission("slapper.remove")) {
                         $this->hitSessions[$sender->getName()] = "on";
                         $sender->sendMessage(TextFormat::GREEN . "[" . TextFormat::YELLOW . "Slapper" . TextFormat::GREEN . "]" . "Hit an entity to remove it");
                     }
                 }
                 if (!($typeToUse === "Nothing") && !($theOne === "Blank")) {
                     $nbt = $this->makeNBT($senderSkin, $isSlim, $name, $humanInv, $playerYaw, $playerPitch, $playerX, $playerY, $playerZ);
                     $clonedHuman = Entity::createEntity($typeToUse, $sender->getLevel()->getChunk($playerX >> 4, $playerZ >> 4), $nbt);
                     $sender->sendMessage(TextFormat::GREEN . "[" . TextFormat::YELLOW . "Slapper" . TextFormat::GREEN . "] " . $theOne . " entity spawned with name " . TextFormat::WHITE . "\"" . TextFormat::BLUE . $name . TextFormat::WHITE . "\"");
                 }
                 if ($typeToUse === "SlapperHuman") {
                     $Inv = $clonedHuman->getInventory();
                     $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());
                 }
                 if (!($theOne == "Blank")) {
                     $clonedHuman->spawnToAll();
                 }
                 if ($typeToUse === "Nothing" || $theOne === "Blank") {
                     $sender->sendMessage("Invalid entity.");
                 }
                 return true;
             } else {
                 $sender->sendMessage("This command only works in game.");
                 return true;
             }
     }
 }