Let's me help you, so you want an ui display all player had joined the server but not the dropdown right
Spoiler: Code PHP: public function sendListUI(Player $player){ //$this->formapi is the FormAPI plugin xD $form = $this->formapi->createSimpleForm(function (Player $player, $data = null){ $target = $data; if($target === null) return true; //... /** * $playername is the name of the player in the button * In this function, $target is the name of the button which had clicked * Also i just can help to here, i don't know what will you gonna do! */ }); $form->setTitle("Epic title"); $form->setContent("More epic lol"); $path = $this->getServer()->getDataPath() . "players/"; foreach(array_diff(scandir($path), array('.', '..')) as $f){ $fe = strtolower(pathinfo($path . $f, PATHINFO_EXTENSION)); if($fe == "dat"){ $playername = str_replace("." . $fe, '', $f); $form->addButton($playername, -1, "", $playername); } } $form->sendToPlayer($player); }
You're welcome PHP: /** @var Player */private $selectedPlayer;public function sendOnlinePlayersForm(Player $player): void { $onlinePlayers = Server::getInstance()->getOnlinePlayers(); $form = new SimpleForm(function(Player $player, ?int $result) use ($onlinePlayers) { if($result !== null) { $this->selectedPlayer = $onlinePlayers[$result]; } }); foreach($onlinePlayers as $onlinePlayer) { $form->addButton($onlinePlayer->getName()); } $player->sendForm($form);}