Hey there, I got this code which gets called when a player tries to get an item from a chest: PHP: // $otherInventory is the chest inventory// I check if the chest inventory is the same like another oneif($otherInventory->getContents() == $this->getShopInventorys()->getStartInvContents()) { // then I cancel the event, so that the player isn't getting the item $event->setCancelled(true); // then I think I have to send the contents so that the item from the chest isn't shown in players inventory $player->getInventory()->sendContents($player); // then I do a foreach to check all the transactions foreach($event->getTransaction()->getTransactions() as $t) { // then I check if the player gets the item from the 0. slot if($t->getSlot() === 0) { // then I change the inventory of the chest $otherInventory->setContents($this->getShopInventorys()->getBlockInvContents()); $player->getInventory()->sendContents($player); } // other if($t->getSlot() === 1,2,3, ....) // end from foreach }// end from if} I want that the player can click on the items and then the chest inventory changes. Now the problem is, that often when I get the item from one slot it shows the inventory it should show when clicking on another slot. So as an example: I click on slot 0 but it shows the inventory it should show when I click on slot 2 or something else than 0. I don't know how to fix that. Maybe someone can help. Thanks in advance.
Because there are two transactions 1. From chest 2. To player inventory So slot is probably of player inventory
So try this (ore something like this) PHP: if($transaction->getInventory() instanceof ChestInventory) { //code}