Try PHP: public function onTransaction(InventoryTransactionEvent $event){ $transactions = $event->getTransaction()->getTransactions(); $player = null; $chestinv = null; $action = null; foreach($transactions as $transaction){ if(($inv = $transaction->getInventory()) instanceof ChestInventory){ foreach($inv->getViewers() as $assumed) if($assumed instanceof Player) { $player = $assumed; $chestinv = $inv; $action = $transaction; break; } } } if($chestinv === null) return; $event->setCancelled(); $item = $action->getTargetItem(); if($item->getName() == "Site 1") { $chestinv->clearAll(); //Slot: $action->getSlot(); //Site 1 }}
This does exactly the same lol. It only works, if I put the item from the chest to the players inv and back
I want to tap a item to change the inventory. But need to tap it and in the same moment tap it again in the players inventory. And that's not what I want
@Muqsit Wouldn't this work for an Interactive Chest Tile? What i mean: 1) Players are able to purchase stuffs but can't add stuffs inside the Chest. 2) Players are able to click on a stuffs and check the price.. I've checked you GitHub here at: https://github.com/Muqsit/ChestShop - Very cool but i need to know the way and how to make a plugin w/o actually copying.. My Loader - I agree this was copied from others for learning purposes: PHP: <?php/* Essentials */use pocketmine\Server;use pocketmine\plugin\PluginBase;use pocketmine\Player;use pocketmine\event\Listener;use pocketmine\command\Command;use pocketmine\command\CommandSender;use pocketmine\utils\TextFormat as TF;use pocketmine\tile\Tile;use pocketmine\tile\Chest;use pocketmine\inventory\ChestInventory;/* Events */use pocketmine\event\inventory\InventoryTransactionEvent;class Loader extends PluginBase implements Listener { public function onEnable() { $this->getServer()->getPluginManager()->registerEvents($this, $this); } public function onChest(InventoryTransactionEvent $e) { $trans = $e->getTransaction()->getTransactions(); foreach($trans as $t) { $inv = $t->getInventory(); if($inv instanceof ChestInventory) { foreach($inv->getViewers() as $assumed) { if($assumed instanceof Player) { $p = $assumed; $cinv = $inv; $action = $t; break; } } } if($inv == null) return; $e->setCancelled(); $item = $action->getTargetItem(); if($item->getName() === "Test") { $sender->sendMessage("Whats this"); } } } public function sendChest(Player $p) { $nbt = new CompoundTag(' ', [ new ListTag('Items', []), new StringTag('id', Tile::CHEST), new IntTag('ChestShop', 1), new IntTag('x', floor($player->x)), new IntTag('y', floor($player->y) - 4), new IntTag('z', floor($player->z)) ]); $tile = Tile::createTile("Chest", $player->getLevel()->getChunk($player->getX() >> 4, $player->getZ() >> 4), $nbt); $p->addWindow($tile->getInventory()); } public function onDisable() { parent::onDisable(); } } I might miss some "use" statements but i'm aware of it.. My GitHub - Just want to show the progress and for me w/o getting lost: https://github.com/RTGDaCoder/Test-ChestTransaction