Hi im trying to test InvMenu currently but I keep on getting this error: [TypeError: "Argument 1 passed to Test\Main::Test\{closure}() must be an instance of pocketmine\Player, instance of muqsit\invmenu\transaction\InvMenuTransaction given] Here's my code: PHP: <?phpnamespace Test;use muqsit\invmenu\{InvMenu, InvMenuHandler};use pocketmine\command\{Command, CommandSender};use pocketmine\item\Item;use pocketmine\nbt\BigEndianNBTStream;use pocketmine\nbt\tag\{CompoundTag, ListTag};use pocketmine\Player;use pocketmine\plugin\PluginBase;use pocketmine\utils\{Config, TextFormat as TF};use pocketmine\event\Listener;class Main extends PluginBase implements Listener{ public function onEnable(){ if (!InvMenuHandler::isRegistered()){ InvMenuHandler::register($this); } } public function onCommand(CommandSender $sender, Command $cmd, string $label, array $args) : bool { switch($cmd->getName()){ case "menu": if($sender instanceof Player){ $menu = InvMenu::create(InvMenu::TYPE_CHEST); $inv = $menu->getInventory(); $menu->readOnly(); $item = Item::get(54, 0, 1); $item->setCustomName("§l§8[§bFREE SHOUTOUT§8]"); $item->setLore(["§l§8----------\n§l§aFree clout for you :)"]); $inv->addItem($item); $menu->setListener(function (Player $player, Item $item, Item $itemClickedWith, SlotChangeAction $action){ if($item->getId() == 53){ $this->getServer()->dispatchCommand($player, "say A player wanted free clout aint gonna do it :)))"); $player->removeWindow($action->getInventory()); } }); $menu->send($sender); } } return true; }}
PHP: $menu->setListener(InvMenu::readonly(function(DeterministicInvMenuTransaction $transaction) : void{ $player = $transaction->getPlayer(); $item = $transaction->getItemClicked(); $itemClickedWith = $transaction->getItemClickedWith(); $inv = $transaction->getAction()->getInventory();});
Replace PHP: $menu->setListener(function (Player $player, Item $item, Item $itemClickedWith, SlotChangeAction $action){ if($item->getId() == 53){ $this->getServer()->dispatchCommand($player, "say A player wanted free clout aint gonna do it :)))"); $player->removeWindow($action->getInventory()); } }); with the given code