Muqsit / InvMenu

A PocketMine-MP virion to create and manage virtual inventories!
https://poggit.pmmp.io/ci/Muqsit/InvMenu/~
GNU General Public License v3.0
201 stars 75 forks source link

on remove window and click item game crash #78

Closed ghost closed 4 years ago

ghost commented 4 years ago

Hi, I've coded this:

    public function warpmenu(Player $player) {
        $menu = InvMenu::create(InvMenu::TYPE_DOUBLE_CHEST);
        $menu->readonly();
        $menu->setName("§bSaerit");
        $inventory = $menu->getInventory();
        $menu->setListener(function(Player $player, Item $itemTakenOut, Item $itemPuttingIn, SlotChangeAction $action) : void {
            if ($itemTakenOut->getId() === Item::DIAMOND) {
                $player->sendMessage("Hello world!");
                $player->removeWindow($action->getInventory());
            }
            if ($itemTakenOut->getCustomName() === "§cClose the menu") {
                $player->sendMessage("yo");
            }
        });
        $inventory->setContents([
            13 => Item::get(Item::DIAMOND, 0, 1)->setCustomName("§bSpawn"),
            45 => Item::get(Item::STAINED_GLASS, 14, 1)->setCustomName("§cClose the menu")
        ]);
        $menu->send($player);
    }

but in the moment I click the diamond, my game crash, if I click the glass dont crash. help

Muqsit commented 4 years ago

Yeah, this is a known issue in v1.16, you'll have to wait until pmmp fixes it (pmmp is already aware of the issue).