Hello fellas. Sure, i already wrote a plugin once, VillagerTrade, that "handeled" transactions, but in 0.15 it stopped working. I actually simply want to create a plugin that detects when an item of a chest was tapped, and give the player for example stone if he tapped cobblestone in the chest (took out/windows 10 edition item at mouse). Would be lovely to know how to do it, and best thing would be if it works with the latest Genisys inventory rewrite, because it supports windows 10 edition. Thanks!
This is the PocketMine forums, not Genisys.. If they change the event, it's not always changed in PocketMine. Since it isn't, this would still work.
But i can espect PocketMine devs to know the PocketMine API. "WOULD", didn't say it has to be written with that API. And just because PM is stuck in 0.11? 4 Totally useless posts extra in this thread.
I use Genisys too and have a code for InventoryTransactionEvent for my BedWars plugin which works well on 15.0. Here is the whole code for the event, edit it: Spoiler PHP: public function onInvTrans(InventoryTransactionEvent $event){$transa = $event->getTransaction()->getTransactions();$int = $event->getTransaction()->getInventories(); foreach ($transa as $t) { foreach ($int as $inst) { $inst = $inst->getHolder(); if ($inst instanceof Player) { $player = $inst; } if ($inst instanceof Chest) { $chest = $inst; }}$trans = $t;}if(!$this->inBedWars($player)) return;$inv = $chest->getInventory();if($chest->namedtag->getName() == "Hub"){$event->setCancelled();$categories = [24, 303, 274, 283, 261, 260, 54, 273, 46]; switch($trans->getTargetItem()->getId()){case 24: // sandstone$chest->getInventory()->clearAll();$chest->namedtag->setName("1");$inv->setItem(0, Item::get(24, 0, 16));$inv->addItem(Item::get(336, 0, 4));$inv->setItem(26, Item::get(35, 14, 1));break;}}else{// villager trading$event->setCancelled();$i = $trans->getTargetItem();if($i->getId() == 336) return;if($i->getId() == 35 && $i->getDamage() == 14){$categories = [24, 303, 274, 283, 261, 260, 54, 273, 46]; $chest->getInventory()->clearAll();foreach($categories as $item){$chest->getInventory()->addItem(Item::get($item, 0, 1));}}$slot = -1;foreach($chest->getInventory()->getContents() as $sloti => $it){if($it->getId() == $i->getId()){$slot = $sloti + 1;}}$priceitem = $chest->getInventory()->getItem($slot);$id = $i->getId();$cost = $priceitem->getCount();$get = $i->getCount();// check amount of bricks in player inv$amount = 0;foreach($player->getInventory()->all(Item::get($priceitem->getId())) as $item){$amount += $item->getCount();}if($amount > $cost || $amount == $cost){$player->getInventory()->removeItem(Item::get($priceitem->getId(), 0, $cost));$item = Item::get($id, 0, $chest->getInventory()->getItem($slot - 1)->getCount());if($item->getId() == 280){$item->addEnchantment(Enchantment::getEnchantment(Enchantment::TYPE_WEAPON_KNOCKBACK));}$player->getInventory()->addItem($item);}else{$player->sendMessage($this->PREFIX."You don't have enough ingredients to buy this item.");}}} I hope I was able to help you!
interesting, added it, fixed variables. shop works, shop villagers are gone and round doesn't start xd
Please stop. @thebigsmileXD can you chill for a bit? Sorry for these memes, but the problem is on the code, not on some American precooked meat. So are you guys working with Genisys or Pocketmine itself? I'll assume it is Genisys. Can you at least show some of your 'not-working' code?
Oh, spamming even more shit into this thread? i hate this forums. I talked with Blueplayz in teamspeak yesterday.. well he is rewriting the whole bedwars thing, but not for the public.
Actually its only that long because he merged several classes into one file. you could easily split the classes.
Back to this. Villager trade is open source. It didn't work anymore in 0.15, used pocketmine before and after The link: https://github.com/thebigsmileXD/VillagerTrade Fun fact: first time i created and uploaded a repo using the git shell only