Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions plugin.yml
Original file line number Diff line number Diff line change
@@ -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]
Expand Down
25 changes: 25 additions & 0 deletions src/jojoe77777/SlapperPlus/FormAPI.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<?php


namespace jojoe77777\SlapperPlus;

use jojoe77777\FormAPI\CustomForm;
use jojoe77777\FormAPI\SimpleForm;

/**
* This class exists for backwards compatibility
* for jojo77777\FormAPI legacy methods
*
* Class FormAPI
* @package jojoe77777\SlapperPlus
*/
class FormAPI {

public function createCustomForm(?callable $function = null) : CustomForm {
return new CustomForm($function);
}

public function createSimpleForm(?callable $function = null) : SimpleForm {
return new SimpleForm($function);
}
}
39 changes: 25 additions & 14 deletions src/jojoe77777/SlapperPlus/Main.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

namespace jojoe77777\SlapperPlus;

use jojoe77777\FormAPI\FormAPI;
use jojoe77777\SlapperPlus\commands\SlapperPlusCommand;
use pocketmine\entity\Entity;
use pocketmine\event\Listener;
Expand Down Expand Up @@ -40,15 +39,17 @@ class Main extends PluginBase implements Listener {
/** @var array */
public $editingId = [];

/** @var FormAPI */
public $formAPI;

public function onEnable() {
$this->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){
Expand All @@ -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);
Expand All @@ -90,5 +102,4 @@ public function makeSlapper(Player $player, int $type, string $name){
$entity->spawnToAll();
$player->sendMessage("§a[§bSlapperPlus§a]§6 Created {$type} entity");
}

}