Code: [19:30:15] [Server thread/CRITICAL]: Could not pass event 'pocketmine\event\server\DataPacketReceiveEvent' to 'FormAPI v1.1.1': Argument 2 passed to gay\command\warp\WarpCommand::gay\command\warp\{closure}() must be of the type array, null given, called in C:\Users\arjxy\Desktop\pocketmine\plugins\FormAPI-master\src\jojoe77777\FormAPI\FormAPI.php on line 75 on jojoe77777\FormAPI\FormAPI [19:30:15] [Server thread/CRITICAL]: TypeError: "Argument 2 passed to gay\command\warp\WarpCommand::gay\command\mine\{closure}() must be of the type array, null given, called in C:\Users\arjxy\Desktop\pocketmine\plugins\FormAPI-master\src\jojoe77777\FormAPI\FormAPI.php on line 75" (EXCEPTION) in "plugin/src/gay/command/warp/WarpCommand" at line 40 line 40 PHP: $form = $api->createSimpleForm(function (Player $player, array $args) {//api is $api = $this->plugin->getServer()->getPluginManager()->getPlugin("FormAPI");
1- try this: PHP: $form = $api->createSimpleForm(function (Player $player, array $args) { 2- if didn't work try to make $api in the top of $form 3- or why don't try to transform array $args to array $data maybe this will fix the problem.
PHP: $api = $this->plugin->getServer()->getPluginManager()->getPlugin("FormAPI"); $form = $api->createSimpleForm(function (Player $player, array $data) { $result = $data[0]; if ($result === null) { return; } switch ($result) { case 0: $sender->sendMessage("ok"); return;
i saw this new thread i didnt know formApi updated $form = $api->createSimpleForm(function (Player $player, ?int $result = null) {
not solved what the crap is going on here i dont see nothing wrong in my code PHP: $api = $player->getServer()->getPluginManager()->getPlugin("FormAPI"); $form = $api->createModalForm(function (Player $sender, array $data) { var_dump($data); }); $form->setTitle("Form Title"); $form->setContent("Text inside form"); $form->setButton1("Button 1"); $form->setButton2("Button 2"); $form->sendToPlayer($player); Code: [Server thread/CRITICAL]: Could not pass event 'pocketmine\event\server\DataPacketReceiveEvent' to 'FormAPI v1.1.1': Argument 2 passed to gay\Main::gay\{closure}() must be of the type array, null given, called in C:\Users\arjxy\Desktop\pocketmine\plugins\FormAPI-master\src\jojoe77777\FormAPI\FormAPI.php on line 75 on jojoe77777\FormAPI\FormAPI [17:29:00] [Server thread/CRITICAL]: TypeError: "Argument 2 passed to gay\Main::gay\{closure}() must be of the type array, null given, called in C:\Users\arjxy\Desktop\pocketmine\plugins\FormAPI-master\src\jojoe77777\FormAPI\FormAPI.php on line 75" (EXCEPTION) in "core/src/gay/Main" at line 20
The $data parameter should be nullable. By writing "array $data", you require it to be an array, not null. To allow null or array, you should write "?array $data".
PHP: /** @var FormAPI $api */ $api = $this->getServer()->getPluginManager()->getPlugin("FormAPI"); $form = $api->createModalForm(function (Player $player, ?array $result) { if ($result === null) { return; } if($result == true){ $player->sendMessage("its true"); } }); $form->setButton1("ook"); $form->setButton2("not ok"); $form->sendToPlayer($player); Code: {closure}() must be of the type array or null, boolean given
It should be ?(Player $player, bool $data). Please don't post answers if you don't know are just guessing (without disclaiming).
createModalForm can give true or false, so it should be bool. createSimpleForm can give an int (the selected index) or null (closed), so it should be ?int. createCustomForm can give null (closed) or an array containing the returned data, so it should be ?array.
createSimpleForm and createCustomForm can also give the label, which is whatever type you set it as previously
createSimpleForm: oops right, I made that change myself and I forgot it createCustomForm still returns an array.