Hey whats the problem here?? Code: public function mainForm($player){ $formapi = $this->getServer()->getPluginManager()->getPlugin("FormAPI"); $form = $formapi->createSimpleForm(function (Player $event, array $data){ $player = $event->getPlayer(); $result = $data[0]; if ($result === null) { } switch ($result) { case 1: } break; }); $form->setTitle("1VS1"); $form->setContent("PROCEED"); $form->addButton("MATCH"); $form->addButton("testc", 1, "https://i.yike.com/yike.jpg"); $form->sendToPlayer($player); }
Here Code: <?php namespace Jamxdrew; use pocketmine\command\Command; use pocketmine\command\CommandSender; use pocketmine\command\ConsoleCommandSenser; use pocketmine\event\player\PlayerRespawnEvent; use pocketmine\Player; use pocketmine\plugin\PluginBase; use pocketmine\Server; use pocketmine\event\Listener; use pocketmine\utils\TextFormat; use jojoe77777\FormAPI; class Loader extends PluginBase implements Listener{ public function onEnable(){ $this->$formapi = $this->getServer()->getPluginManager()->getPlugin("FormAPI"); if(!$this->$formapi or $this->$formapi->isDisabled()){ $this->getLogger()->warning('Dependency FormAPI not found, disabling...'); $this->getPluginLoader()->disablePlugin($this); } $this->getServer()->getPluginManager()->registerEvents(new Listener($this), $this); $this->getServer()->getLogger()->info(TextFormat::AQUA . 'TestUI enabled. ' . TextFormat::GRAY . 'Made by Jam with ' . TextFormat::RED . "\xe2\x9d\xa4"); } public function onDisable(){ $this->getLogger()->info(TextFormat::DARK_RED . "I've been disabled!"); } public function onCommand(CommandSender $sender, Command $command, $label, array $args): bool{ switch($command->getName()){ case "ui": $this->$mainForm($player); break; } return true; } public function mainForm($player){ $this = $formapi->getServer()->getPluginManager()->getPlugin("FormAPI"); $form = $fromapi->createSimpleForm(function (Player $event, array $data){ $result = $data[0]; if ($result === null) { } switch ($result) { case 1: $this->getServer()->getCommandMap()->dispatch($player,"matchs"); } return true; } }); $form->setTitle("1VS1"); $form->setContent("PROCEED"); $form->addButton("MATCH"); $form->sendToPlayer($player); } }
Code: <?php namespace Jamxdrew; use pocketmine\command\Command; use pocketmine\command\CommandSender; use pocketmine\event\Listener; use pocketmine\event\player\PlayerRespawnEvent; use pocketmine\Player; use pocketmine\plugin\PluginBase; use pocketmine\Server; use pocketmine\event\Listener; use pocketmine\utils\TextFormat; use jojoe77777\FormAPI; class Loader extends PluginBase implements Listener{ public function onEnable(){ $this->getServer()->getPluginManager()->registerEvents($this, $this); $this->getLogger()->info(TextFormat::DARK_GREEN . "I've been enabled!"); } public function onDisable(){ $this->getLogger()->info(TextFormat::DARK_RED . "I've been disabled!"); } public function onCommand(CommandSender $sender, Command $command, $label, array $args): bool{ $player->$sender->getPlayer(); switch($command->getName()){ case "ui": $this->$mainForm($player); break; } return true; } public function mainForm($player){ $formapi = $this->getServer()->getPluginManager()->getPlugin("FormAPI"); $form = $formapi->createSimpleForm(function (Player $event, array $data){ $result = $data[0]; if ($result === null) { } switch ($result) { case 1: $this->getServer()->dispatchCommand($event->getPlayer(), "match"); } break; } }); $form->setTitle("1VS1"); $form->setContent("PROCEED"); $form->addButton("MATCH"); $form->sendToPlayer($player); } Here