public function execute(CommandSender $sender, $alias, array $args)
 {
     if ($sender instanceof Player) {
         $packet = new SetHealthPacket();
         $packet->health = $sender->getHealth();
         $sender->dataPacket($packet);
         return true;
     }
     $sender->sendMessage("Please run this command in-game. If you want to know your device's health, don't ask me.");
     return false;
 }
 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;
             }
     }
 }