PHP: public function onCommand(CommandSender $sender, Command $cmd, string $label, array $args) : bool{ switch($cmd->getName()){ case "info" : if ($sender instanceof Player){ $this->openInfoForm ($sender); } break; switch($cmd->getName()){ case "ranks" : if ($sender instanceof Player){ $this->openRanksForm ($sender); } break; } } return true; } PHP: public function openInfoForm(Player $player){ $form = new \jojoe77777\FormAPI\SimpleForm(function (Player $sender, $data){ if ($data === null) { return true; } switch($data) { case 0: return true; break; case 1: return true; break; } return true; }); $form->setTitle("§f§l• §5Purple§fCraft •"); $form->setContent("§5§nInformations \n \n \n§5SOON"); $form->addButton("§5Buy a rank§f \n§fDiscord §5-> §fAl3x#1178"); $form->addButton("§fClose"); $form->sendToPlayer($player); } ////////public function openRanksForm(Player $player){ $form = new \jojoe77777\FormAPI\SimpleForm(function (Player $sender, $data){ if ($data === null) { return true; } switch($data) { case 0: return true; break; case 1: return true; break; } return true; }); $form->setTitle("§f§l• §5Purple§fCraft §f§l•"); $form->setContent("VIP"); $form->addButton("Hi"); $form->sendToPlayer($player); } PHP: commands: ranks: description: "Do /ranks to see ranks" Command /ranks exist but it doesnt work, for some reason it does exactly nothing when i execute it. There's no error..its just..doing nothing even tho it should open openRanksForm (/info and openInfoForm are working without any problems, they are just an example)
Why do you put the switch in another switch? Just this would do PHP: switch($cmd->getName()){ case "info" : if ($sender instanceof Player){ $this->openInfoForm ($sender); } break; case "ranks" : if ($sender instanceof Player){ $this->openRanksForm ($sender); } break; }
PHP: public function onCommand(CommandSender $sender, Command $cmd, string $label, array $args) : bool{ switch($cmd->getName()){ case "info" : if($sender instanceof Player){ $this->openInfoForm($sender); } break; case "ranks" : if($sender instanceof Player){ $this->openRanksForm($sender); } break; } return true; }