InvMenu
InvMenu copied to clipboard
Inv Bug
I have a problem with the discard on my server, it's bug my inventory
https://github.com/Muqsit/InvMenu/assets/125693577/6ab7634f-c78e-445d-81ee-f9e95ab3210c
Can you share the relevant code and describe the intended outcome of it?
`` $menu->setListener(function (InvMenuTransaction $transaction) use ($player,$menu): InvMenuTransactionResult {
$blockclick = $transaction->getItemClicked()->getBlock();
$itemin = $transaction->getIn();
if ($transaction->getItemClicked()->getVanillaName() === "Stained Glass Pane") {
$player->sendMessage("You cannot take apples out of that inventory.");
return $transaction->discard();
}
if ( $itemin->getVanillaName() === "Nether Wart" and $itemin->getCount() == 64){
$menu->getInventory()->setItem(15, VanillaBlocks::WOOL()->setColor(DyeColor::LIME())->asItem()->setCustomName("§aTransformer"));
} else $menu->getInventory()->setItem(15, VanillaBlocks::WOOL()->setColor(DyeColor::RED())->asItem()->setCustomName("§c64x cannabis requis"));
if ($blockclick instanceof Wool) {
if ($blockclick->getColor() === DyeColor::LIME()) {
$menu->getInventory()->setItem(11, VanillaItems::AIR());
$rdm = random_int(1, 50);
if ($rdm == 35) {
$player->getInventory()->addItem(VanillaItems::DYE()->setColor(DyeColor::GREEN()));
$player->sendMessage("§pVous avez reçu un bedo !");
} else {
$player->sendMessage("§cVous n'avez pas eu de chance pour transformer votre cannabis !");
}
}
return $transaction->discard();
}
return $transaction->continue();
});
`` if I put nether wart in slot 11, the green wool appears in slot 15 then if I click on it it launches a random event to give me a reward