So I'm adding a result to switch but whenever I add an if statement, it doesn't work and acts as if whatever is below isn't there. When I end the if statement and run somethint else by itself, it works fine. I'm very confused, please help me.
PHP: public function onCommand(CommandSender $sender, Command $cmd, string $label, array $args): bool{ $formapi = $this->getServer()->getPluginManager()->getPlugin("FormAPI"); $form = $formapi->createSimpleForm(function (Player $player, int $data = null){ $result = $data; if ($result === null) { return; } if($result === 1) { $chance = mt_rand(0,1); # For test purposes if ($chance === 1) { $this->getServer()->dispatchCommand(new ConsoleCommandSender(), 'enchant '.$sender->getName().' efficiency 1'); } } switch ($result) { case 0: break; } return; } ); $form->setTitle("Random Enchants"); $form->addButton("TEST"); $form->sendToPlayer($sender); return true; }}
PHP: if ($result === 1){$chance = mt_rank(0,1);switch ($chance){case 1:$this->getServer()->dispatchCommand(new ConsoleCommandSender(), 'enchant '.$sender->getName().' efficiency 1');break;}} I dont think you need that other switch