Thank you very much! One more question. Is it possible to get the position of the chest where the transaction occurred? And maybe also the player object?
Find out the transaction which has a ChestInventory item, and get the holder of the ChestInventory. The holder should be a pocketmine\tile\Chest object, which is an instance of Vector3.
Solved it myself, here is the code PHP: public function InventoryTransfer(InventoryTransactionEvent $event){ $trans = $event->getTransaction()->getTransactions(); $inv = $event->getTransaction()->getInventories(); foreach($trans as $t){ foreach($inv as $chest){ if (!($chest instanceof ChestInventory)){ return; } $chest = $chest->getHolder(); if(!($chest instanceof Chest)){ return; } $x = $chest->x; $y = $chest->y; $z = $chest->z; $l = $chest->getBlock()->getLevel()->getName(); $i = $t->getTargetItem(); $i2 = $t->getSourceItem(); if ($i->getId() === 0){ $i = $i2; } $n = $i->getName(); $d = $i->getDamage(); $c = $i->getCount(); var_dump($n.":".$d." ".$c." at ".$x." ".$y." ".$z." ".$l); } } } Is it possible to get the player who initiated the transaction?
When I do if($chest instanceof PlayerInventory){ $this->player = $chest->getHolder(); } It says that player is null, any way to bypass it?
If you want to ask some question, you should make a new thread for that, because the problem in this thread already solved few months ago
Then link to this thread. Only reply to an old thread when you want to provide additional information or correct some serious mistakes.