Closed CaptainDuck closed 4 years ago
This doesn't tell me how to reproduce the bug.
I just used a command for the code above
This code doesn't run because it's incomplete.
The code is meant to be incomplete, I didn't want to add more code for the commands part. The menu was sent, I tried the code and the result was still the same. Do you need a video for demonstration?
I'm not wasting my time trying to figure out what I need to do to your code in order to make it reproduce the bug. Either provide working code or don't bother.
Main.php:
<?php
namespace RemoveWindowBug;
use jojoe77777\FormAPI\ModalForm;
use muqsit\invmenu\InvMenu;
use pocketmine\command\Command;
use pocketmine\command\CommandSender;
use pocketmine\inventory\transaction\action\SlotChangeAction;
use pocketmine\item\Item;
use pocketmine\Player;
use pocketmine\plugin\PluginBase;
class Main extends PluginBase
{
public function onCommand(CommandSender $sender, Command $command, string $label, array $args): bool
{
if($sender instanceof Player && $command->getName() === "removetest"){
$menu = InvMenu::create(InvMenu::TYPE_DOUBLE_CHEST);
$menu->readonly();
$menu->setListener(function (Player $player, Item $itemClicked, Item $itemClickedWith, SlotChangeAction $action) {
$form = new ModalForm(null);
$form->setButton1("Yes");
$form->setButton2("No");
$player->removeWindow($action->getInventory());
$player->sendForm($form);
}
);
$menu->send($sender);
}
return true;
}
}
plugin.yml:
name: RemoveWindowBug
version: 1.0.0
api: 3.0.0
author: CaptainDuck
main: RemoveWindowBug\Main
commands:
removetest:
default: true
description: Test the bug
Hi @CaptainDuck . To accomplish this we:
setInventoryCloseListener()
, setListener()
is for things like moving items in the inventory. Use it like this: setInventoryCloseListener(Player $player, InvMenuInventory $inventory)
.$player->getInventory()
. It also doesn't give you the opened inventory, and trying to remove it like that gives errors.It will end like this:
<?php
namespace RemoveWindowBug;
use jojoe77777\FormAPI\ModalForm;
use muqsit\invmenu\InvMenu;
use muqsit\invmenu\inventory\InvMenuInventory;
use pocketmine\command\Command;
use pocketmine\command\CommandSender;
use pocketmine\inventory\transaction\action\SlotChangeAction;
use pocketmine\item\Item;
use pocketmine\Player;
use pocketmine\plugin\PluginBase;
class Main extends PluginBase
{
public function onCommand(CommandSender $sender, Command $command, string $label, array $args): bool
{
if($sender instanceof Player && $command->getName() === "removetest"){
$menu = InvMenu::create(InvMenu::TYPE_DOUBLE_CHEST);
$menu->readonly();
$inventory = $menu->getInventory();
$menu->setInventoryCloseListener(function (Player $player, InvMenuInventory $inventory){
$form = new ModalForm(null);
$form->setButton1("Yes");
$form->setButton2("No");
$player->removeWindow($action->getInventory());
$player->sendForm($form);
}
);
$menu->send($sender);
}
return true;
}
}
You have my Discord
Kevin.#1234
Thanks for trying to help but what I'm trying to do is that when a player does something with the inventory, it will close and a modal form will open.. this wasn't an issue before v1.16 and worked just as expected. 😞
FWIW, I doubt this is a PM issue since nothing has changed regarding form handling. It's not likely there's any fix or solution to this.
Solved with InvMenu's v4.0.0 update, thank you for your time :)
Issue description
Steps to reproduce the issue
removeAllWindows();
function for the Player, but still it didn't work.OS and versions
Plugins
Code to reproduce: