Он его просто игнорит, он включен но не работает

В плагине я использовал FormAPI
Devtools установи
Он же установлен или ты не видишь?
Я просто прочитал, т.к. я гуляю
покажи фулл код, возможно ты не добавил Listener
Вот мой (мб гкод) код
<?php
declare(strict_types=1);
namespace Melvi;
use pocketmine\command\Command;
use pocketmine\command\CommandSender;
use pocketmine\event\block\BlockBreakEvent;
use pocketmine\event\Listener;
use pocketmine\event\player\PlayerMoveEvent;
use pocketmine\item\enchantment\EnchantmentInstance;
use pocketmine\item\enchantment\StringToEnchantmentParser;
use pocketmine\item\Item;
use pocketmine\player\Player;
use pocketmine\plugin\PluginBase;
use pocketmine\utils\Config;
use pocketmine\item\VanillaItems;
use pocketmine\math\AxisAlignedBB;
class Main extends PluginBase implements Listener
{
public $config;
public Portal $portal;
public function onEnable(): void
{
$this->getServer()->getPluginManager()->registerEvents($this, $this);
if (!is_dir($this->getDataFolder())) mkdir($this->getDataFolder());
$this->config = new Config($this->getDataFolder()."portals.json", Config::JSON);
$this->getLogger()->alert("ПЛАГИН ВКЛЮЧЕН БЛЕТ");
}
public function onCommand(CommandSender $sender, Command $command, string $label, array $args): bool
{
if ($command->getName() == "createportal") {
if (!$sender instanceof Player) { $sender->sendMessage("низя"); return false; }
$this->getLogger()->alert("Player run cp");
$this->createMenu($sender);
return true;
}
return true;
}
public function createMenu(Player $p)
{
$api = $this->getServer()->getPluginManager()->getPlugin("FormAPI");
$form = $api->createCustomForm(function (Player $p, array $data = null) {
if ($data === null)
{
return true;
}
$this->portal->name = $data[0];
$this->portal->ip = $data[1];
$this->portal->port = $data[2];
$p->getInventory()->addItem($this->getStickMagic());
});
$form->setTitle("Создать портал");
$form->addInput("Для начала нужно выбрать название порталу", "Введите название");
$form->addInput("Затем нужно айпи сервера для переноса", "Введите айпи");
$form->addInput("А теперь нужно ввести порт", "Порт", "19132");
$form->sendToPlayer($p);
}
public function getStickMagic() : Item
{
$item = VanillaItems::STICK();
$item->setCustomName("§aПалочка выделялочка");
$enchantName = StringToEnchantmentParser::getInstance()->parse("Unbreaking");
$item->addEnchantment(new EnchantmentInstance($enchantName, 1));
return $item;
}
public function onBreakBlock(BlockBreakEvent $e)
{
$item = $e->getItem();
$firstPos = null;
$secondPos = null;
if ($item->getId() == 280 && $item->getCustomName() == "§aПалочка выделялочка")
{
if ($firstPos == null)
{
$firstPos = $e->getBlock()->getPosition();
$e->getPlayer()->sendMessage("§aТеперь выделите вторую позицию");
}
if ($firstPos != null && $secondPos == null)
{
$secondPos = $e->getBlock()->getPosition();
$e->cancel();
}
if ($firstPos != null && $secondPos != null)
{
$this->portal->minX = $firstPos->getX();
$this->portal->minY = $firstPos->getY();
$this->portal->minZ = $firstPos->getZ();
$this->portal->maxX = $secondPos->getX();
$this->portal->maxY = $secondPos->getY();
$this->portal->maxZ = $secondPos->getZ();
$e->getPlayer()->getInventory()->remove($this->getStickMagic());
$this->createPortalToCfg();
}
}
}
public function createPortalToCfg()
{
$data["portals"] = [$this->portal->name => [
"minX" => $this->portal->minX,
"minY" => $this->portal->minY,
"minZ" => $this->portal->minZ,
"maxX" => $this->portal->maxX,
"maxY" => $this->portal->maxY,
"maxZ" => $this->portal->maxZ,
"serverIp" => $this->portal->ip,
"port" => $this->portal->port
]];
$this->config->setAll($data);
$this->config->save();
}
public function onMovePlayer(PlayerMoveEvent $e)
{
foreach ($this->getAllPortals()['portals'] as $portal)
{
$aabb = new AxisAlignedBB($portal['minX'], $portal['minY'],$portal['minZ'],$portal['maxX'],$portal['maxY'],$portal['maxZ']);
$playerAABB = $e->getPlayer()->getBoundingBox();
if ($aabb->intersectsWith($playerAABB))
{
$e->getPlayer()->transfer($portal['ip'], $portal['port']);
}
}
}
public function getAllPortals() : array
{
$data = $this->config->getAll();
return var_dump($data);
}
}
class Portal {
public $name = null;
public $maxX = null;
public $minX = null;
public $maxY = null;
public $minY = null;
public $maxZ = null;
public $minZ = null;
// public TypePortal $type;
// public int $x, $y, $z;
public string $ip;
public int $port;
}
class TypePortal {
public const XYZ = 1;
public const SERVER = 2;
}
на сколько я знаю в пммп4 надо писать onLoad, так что не удивительно что ничего не работает, евенты плагина не регистрируется
тоже не помогло, он его игнорит
а команды работают?
нет
должно выводится ‘низя’
if (!$sender instanceof Player) { $sender->sendMessage("низя"); return false; }
ну не знаю, магия какая то, где то наверняка тупая ошибка
Ну и главное это только с моим плагином, иногда он с 10 попытки может включится
а можно пжпжпжп не писать каждую возникающую ошибку на форум
Извиняюсь
наверное я опоздал но попробуй
protected function onEnable() : void
{
//TODO
}
чем протектед поможет