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

Menus do not open #167

Closed xSuperr closed 2 years ago

xSuperr commented 2 years ago

When I send a player an InvMenu they do not receive it, but upon opening their inventory and closing it the menu appears. I have also consoled other developers and they have had this same issue. I can provide code snippets if required.

Muqsit commented 2 years ago

Yeah a code snippet and a video would be nice.

xSuperr commented 2 years ago

Command:

        SkyblockPlayer::get($sender->getUniqueId(), function (?array $data) use ($sender, $args): void {
            if ($data === null) return;

            if ($data['island'] !== null) {
                $sender->sendMessage('§r§cYou are already in an island!');
                return;
            }

            $name = $args['name'] ?? null;

            (new IslandCreateMenu($sender, $this->plugin, $name))->display();
        });

Menu:

     public function display(): void
    {
        $manager = InvMenuHandler::getPlayerManager();
        if ($manager->get($this->player) === null) return;
        $oldMenu = $manager->get($this->player)->getCurrent();
        if ($oldMenu !== null) {
            $this->onClose($this->player);
            self::$awaitingClose[$this->player->getName()] = $this;
        } else {
            $this->send($this->player);
        }
    }

Video

Muqsit commented 2 years ago

There's a lot happening in that display() method, I'm not sure if I can directly attribute this to InvMenu without understanding what all of that's for. I'd suggest further debugging the issue on your end.

xSuperr commented 2 years ago

I have two potential causes: A. Light blocks, I replaced all air blocks in my spawn with light blocks, a block similar to barriers but that wouldn't make any sense because it was the same issue while in an area without light blocks. B. WaterdogPE, I will test the InvMenu without waterdog in a minute

Edit: can confirm it is not waterdog

Muqsit commented 2 years ago

A minimal reproduction test case would be better for both of us. From what I understood, sending a menu doesn't work until the player opens their inventory, correct? Does the following code work?

InvMenu::create(InvMenu::TYPE_CHEST)->send($player);
xSuperr commented 2 years ago

Yeah that works without issue, it is most likely a problem on my part. Sorry about the trouble.