Right now im trying to make a menu plugin using API from: https://github.com/Muqsit/InvMenu/wiki/Examples. But it says that I need to register InvMenuHandler, would I just create the file paste the class and that's it?
lmao what just copy and paste this on your onEnable() PHP: if(InvMenuHandler::isRegistered()){ InvMenuHandler::register($this); }
invert the if case. Right below it, there's an example on how to do it. PHP: if(!InvMenuHandler::isRegistered()){ InvMenuHandler::register($this);}
PHP: if(strtolower($command->getName()) === "test"){ class ServerSelectorGUI{ /** @var InvMenu */ private $menu; 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 ->onInventoryClose(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->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); } } $gui = new ServerSelectorGUI("Server Selector"); $gui->addServerToList(Item::get(Item::DIAMOND_PICKAXE), "play.onmyserverplea.se", 19132); $gui->addServerToList(Item::get(Item::IRON), "play.onmyserverplea.se", 19133); /** @var Player $player */ $gui->sendTo($player); return true; } return false; return true; } return false; Error that i get: Code: [Server thread/CRITICAL]: ParseError: "syntax error, unexpected 'return' (T_RETURN), expecting function (T_FUNCTION) or const (T_CONST)" (EXCEPTION) in "plugins/GladeNation Core/src/GladeNationCore/Main" at line 139