I'm working on a custom plugin and I need help: Error: Code: [14:58:14] [Server thread/CRITICAL]: TypeError: "Argument 1 passed to Commands\ServerSelectorGUI::sendTo() must be an instance of Commands\Player, instance of pocketmine\Player given, called in /root/mcpe/plugins/Commands/src/Commands/Main.php on line 98" (EXCEPTION) in "plugins/Commands/src/Commands/Main" at line 48 Code: PHP: public function __construct(string $name){$this->menu = InvMenu::create(InvMenu::TYPE_CHEST)->readonly()->setName($name)->setListener([$this, "onServerSelectorTransaction"])//you can call class functions this way->setInventoryCloseListener(function(Player $player) : void{$player->sendMessage(TextFormat::GREEN . "You are being transferred...");});}public function addServerToList(Item $item, string $address, int $port) : void{$nbt = $item->getNamedTag();$nbt->setString("Server", $address . ":" . $port);$item->setNamedTag($nbt);$this->menu->getInventory()->addItem($item);}public function onServerSelectorTransaction(Player $player, Item $itemClickedOn) : bool{$player->transfer(...explode(":", $itemClickedOn->getNamedTag()->getString("Server", "play.onthefallbackserv.er:19132")));return true;}public function sendTo(Player $player) : void{$this->menu->send($player);}}class Main extends PluginBase{public function onLoad(): void{$this->getLogger()->info(C::GREEN . "Loading Commands...");}public function onEnable(): void{$this->getLogger()->info(C::YELLOW . "Enabled Commands!");if(!InvMenuHandler::isRegistered()){InvMenuHandler::register($this);}}public function onDisable(): void{$this->getLogger()->info(C::RED . "Commands Disabled!");}public function onCommand(CommandSender $sender, Command $command, string $label, array $args): bool{switch($command){case "test":$sender->sendMessage("Test works :)");break;case "transfer":$player = $sender->getPlayer();$gui = new ServerSelectorGUI("Server Selector");$gui->addServerToList(Item::get(Item::DIAMOND_PICKAXE), "play.onmyserverplea.se", 19132);$gui->addServerToList(Item::get(Item::IRON_INGOT), "play.onmyserverplea.se", 19133);$gui->sendTo($player);break;}return true;}}
Wow thx it works now! One more question, how would I add a custom name to the item, for example this code: PHP: $gui->addServerToList(Item::get(Item::DIAMOND_PICKAXE), "play.onmyserverplea.se", 19132);