Closed AngelliaX closed 4 years ago
@TungstenVn can you provide any code samples that does that?
- <?php
- namespace TungstenVn\Gomoku\commands;
- use TungstenVn\Gomoku\Gomoku;
-
- use muqsit\invmenu\InvMenu;
- use muqsit\invmenu\InvMenuHandler;
- class commands extends Command implements PluginIdentifiableCommand {
-
- public $main,$menu;
-
- public function __construct(Gomoku $main) {
- parent::__construct("gom", "Gomoku command", ("/gom help"), []);
- $this->main = $main;
if(!InvMenuHandler::isRegistered()){
InvMenuHandler::register($this);
}
- }
-
- public function execute(CommandSender $sender, $commandLabel, array $args)
- {
- $main = $this->main;
- if ($sender instanceof Player) {
- if (!isset($args[0])) {
- #$sender->sendMessage("§6Please use: ".$this->getUsage());
- $this->menu = InvMenu::create(InvMenu::TYPE_CHEST)
- ->readonly()
- ->setName($name)
- ->setListener([$this, "onTransaction"]);
- $this->menu->getInventory()->addItem(Item::get(Item::CHEST)->setCustomName("Click Me!"));
- $this->menu->send($sender);
- }
- } else {
- print("Please run command in-game.\n");
- }
- }
-
- public function onTransaction(Player $player, Item $itemTakenOut, Item $itemPutIn, SlotChangeAction $inventoryAction) : void{
- var_dump("alo");
- }
- public function getPlugin(): Plugin
- {
- return $this->Plugin;
- }
- }
it was sth like this, i also have
if(!InvMenuHandler::isRegistered()){
InvMenuHandler::register($this);
}
in the Main.php(Gomoku.php)
The code seems to work fine... as far as the client is concerned. The inventory bugs of failed items persisting are not caused by InvMenu. It has existed since a few minecraft versions back.
https://github.com/Muqsit/InvMenu/wiki/Examples#close-an-inventory-when-player-clicks-an-item
if i put sth from my own inventory to the fake inventory then i click the chest, the event function (onTransaction()) wont be excuted