diff --git a/plugin.yml b/plugin.yml index 0984a02..2c2c588 100644 --- a/plugin.yml +++ b/plugin.yml @@ -1,7 +1,7 @@ name: SlapperPlus main: jojoe77777\SlapperPlus\Main -version: 1.0.2 -api: [3.0.0-ALPHA9, 3.0.0-ALPHA10, 3.0.0-ALPHA11] +version: 2.0.2 +api: [3.0.0] author: jojoe77777 description: Add-on plugin for Slapper depend: [Slapper, FormAPI] diff --git a/src/jojoe77777/SlapperPlus/FormAPI.php b/src/jojoe77777/SlapperPlus/FormAPI.php new file mode 100644 index 0000000..56c65e8 --- /dev/null +++ b/src/jojoe77777/SlapperPlus/FormAPI.php @@ -0,0 +1,25 @@ +formAPI = new FormAPI(); $this->getServer()->getPluginManager()->registerEvents($this, $this); $this->getServer()->getCommandMap()->register("slapperplus", new SlapperPlusCommand($this)); } public function getFormAPI() : FormAPI { - /** @var FormAPI $api */ - $api = $this->getServer()->getPluginManager()->getPlugin("FormAPI"); - return $api; + return $this->formAPI; } public function onPlayerQuit(PlayerQuitEvent $ev){ @@ -59,28 +60,39 @@ public function onPlayerQuit(PlayerQuitEvent $ev){ public function makeSlapper(Player $player, int $type, string $name){ $type = self::ENTITY_LIST[$type]; $nbt = new CompoundTag(); - $nbt->Pos = new ListTag("Pos", [ + $pos = new ListTag("Pos", [ new DoubleTag("", $player->getX()), new DoubleTag("", $player->getY()), new DoubleTag("", $player->getZ()) ]); - $nbt->Motion = new ListTag("Motion", [ + $motion = new ListTag("Motion", [ new DoubleTag("", 0), new DoubleTag("", 0), new DoubleTag("", 0) ]); - $nbt->Rotation = new ListTag("Rotation", [ + $rotation = new ListTag("Rotation", [ new FloatTag("", $player->getYaw()), new FloatTag("", $player->getPitch()) ]); - $nbt->Health = new ShortTag("Health", 1); - $nbt->Commands = new CompoundTag("Commands", []); - $nbt->MenuName = new StringTag("MenuName", ""); - $nbt->SlapperVersion = new StringTag("SlapperVersion", $this->getServer()->getPluginManager()->getPlugin("Slapper")->getDescription()->getVersion()); + $health = new ShortTag("Health", 1); + $commands = new CompoundTag("Commands", []); + $menuName = new StringTag("MenuName", ""); + $slapperVersion = new StringTag("SlapperVersion", $this->getServer()->getPluginManager()->getPlugin("Slapper")->getDescription()->getVersion()); + + $nbt->setTag($pos); + $nbt->setTag($motion); + $nbt->setTag($rotation); + $nbt->setTag($health); + $nbt->setTag($commands); + $nbt->setTag($menuName); + $nbt->setTag($slapperVersion); + if($type === "Human") { $player->saveNBT(); - $nbt->Inventory = clone $player->namedtag->Inventory; - $nbt->Skin = new CompoundTag("Skin", ["Data" => new StringTag("Data", $player->getSkin()->getSkinData()), "Name" => new StringTag("Name", $player->getSkin()->getSkinId())]); + $inventory = clone $player->namedtag->getListTag("Inventory"); + $skin = new CompoundTag("Skin", ["Data" => new StringTag("Data", $player->getSkin()->getSkinData()), "Name" => new StringTag("Name", $player->getSkin()->getSkinId())]); + $nbt->setTag($inventory); + $nbt->setTag($skin); } $entity = Entity::createEntity("Slapper{$type}", $player->getLevel(), $nbt); $entity->setNameTag($name); @@ -90,5 +102,4 @@ public function makeSlapper(Player $player, int $type, string $name){ $entity->spawnToAll(); $player->sendMessage("§a[§bSlapperPlus§a]§6 Created {$type} entity"); } - }