PHP: public function crateUI(Player $player) : void{ $this->cfg = $this->plugin->getPlayerCfg($player); $form = $this->plugin->FormAPI->createSimpleForm(function (Player $player, array $data){ $result = $data[0]; if($result != null){ } switch($result){ case 1: $player->sendMessage("D"); break; } }); $form->setTitle(C::BLUE . "Crates List"); $form->setContent(""); $form->addButton("Hello"); $form->addButton("Hellof", 1); $form->addButton(C::RED . "Vote " . C::GRAY . "- " . C::YELLOW . $this->cfg->get("Vote")); $form->addButton(C::GOLD . "Rare " . C::GRAY . "- " . C::YELLOW . $this->cfg->get("Rare")); $form->addButton(C::AQUA . "Legendary " . C::GRAY . "- " . C::YELLOW . $this->cfg->get("Legendary")); $form->sendToPlayer($player); } this code isnt work when i click Hellof it doesnt send msg
https://github.com/jojoe77777/FormAPI/blob/master/src/jojoe77777/FormAPI/SimpleForm.php#L92 There are not enough arguments required to display the image.
Oops... sorry SimpleForm returns the key (integer) of the pressed button, not an array. please rewrite as follows. PHP: $form = $this->plugin->FormAPI->createSimpleForm(function (Player $player, $data){ if($data !== null){ switch($data){ case 1: $player->sendMessage("D"); break; } }});
Yuko is right, formapi's simple form doesnt return an array anymore. So it should be PHP: $form = $this->plugin->FormAPI->createSimpleForm(function (Player $player, $data){ Could you maybe share the error if it still doesnt work?
I saw the plugin at GitHub and found that the usage of FormAPI is incorrect. Since FormAPI is an independent plugin, it is not intended for use in embedded applications. For details, please see the following. https://github.com/jojoe77777/FormAPI
Instead of incorporating FormAPI as a UIAPI folder, you need to load it as a single plugin separate from the Crate plugin. as) Plugins(2) CrateSystem, FormAPI