Totally new to minecraft plugins I want to type a command ( "/test") then be shown a basic modal form with around 4 buttons, with each one to perform its own command (example "/spawn") do I need any dependencies for this? and is there a template plugin I can use to build upon? I understand the need for a plugin.yml in root where I would set the command and plugin details; Code: name: MyPlugin version: 1.0.0 author: navypixel api: [3.4.0] main: navypixel\myplugin\MyPlugin commands: test: description: OPENS A FORMUI usage: /test <usage here> then the myplugin.php needs to start with the namespace and I guess an OnEnable function. if someone has some basic template for the php file I can hopefully work on that and add/remove what is needed. thanks
PHP: <?phpnamespace navyPixel\myplugin;use pocketmine\Player;use pocketmine\Server;use pocketmine\plugin\PluginBase;use pocketmine\command\Command;use pocketmine\command\CommandSender;use pocketmine\event\Listener;use jojoe77777\FormAPI;use jojoe77777\FormAPI\SimpleForm;class MyPlugin extends PluginBase implements Listener { public function onEnable() { $this->getServer()->getPluginManager()->registerEvents($this, $this); } public function onCommand(CommandSender $sender, Command $cmd, string $label, array $args) : bool { switch ($cmd->getName()) { case "test": if($sender instanceof Player) { $this->mainMenu($sender); } break; } return true; } public function mainMenu($player) { $api = $this->getServer()->getPluginManager()->getPlugin("FormAPI"); $form = $api->createSimpleForm(function (Player $player, ?int $data) { if ($data === null) { return true; } switch($data) { case 0: case 1: case 2: case 3: break; } }); $form->setTitle("Main Form"); $form->addButton("Button 1"); $form->addButton("Button 2"); $form->addButton("Button 3"); $form->addButton("Button 4"); $form->sendToPlayer($player); return $form; }} If you want it to execute an existing command when they click one of the buttons, you can use dispatchCommand in the cases.
legend, I can work with this, is it possible for a form button to go to another form (a sub menu with a back button?)
PHP: <?phpnamespace navyPixel\myplugin;use pocketmine\Player;use pocketmine\Server;use pocketmine\plugin\PluginBase;use pocketmine\command\Command;use pocketmine\command\CommandSender;use pocketmine\event\Listener;use jojoe77777\FormAPI;use jojoe77777\FormAPI\SimpleForm;class MyPlugin extends PluginBase implements Listener { public function onEnable() { $this->getServer()->getPluginManager()->registerEvents($this, $this); } public function onCommand(CommandSender $sender, Command $cmd, string $label, array $args) : bool { switch ($cmd->getName()) { case "test": if($sender instanceof Player) { $this->mainMenu($sender); } break; } return true; } public function mainMenu($player) { $api = $this->getServer()->getPluginManager()->getPlugin("FormAPI"); $form = $api->createSimpleForm(function (Player $player, ?int $data) { if ($data === null) { return true; } switch($data) { case 0: $this->subMenu($player); break; case 1: case 2: case 3: break; } }); $form->setTitle("Main Form"); $form->addButton("Button 1"); $form->addButton("Button 2"); $form->addButton("Button 3"); $form->addButton("Button 4"); $form->sendToPlayer($player); return $form; } public function subMenu($player) { $api = $this->getServer()->getPluginManager()->getPlugin("FormAPI"); $form = $api->createSimpleForm(function (Player $player, ?int $data) { if ($data === null) { return true; } switch($data) { case 0: break; case 1: $this->mainMenu($player); break; } }); $form->setTitle("Sub Form"); $form->addButton("Button 1"); $form->addButton("Back"); $form->sendToPlayer($player); return $form; }} You can have one of the buttons named "Back", and put the case to open the mainForm.