InvMenu icon indicating copy to clipboard operation
InvMenu copied to clipboard

Inv Bug

Open Driwen4356 opened this issue 2 years ago • 2 comments

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

Driwen4356 avatar Sep 23 '23 22:09 Driwen4356

Can you share the relevant code and describe the intended outcome of it?

Muqsit avatar Sep 23 '23 22:09 Muqsit

`` $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

Driwen4356 avatar Sep 24 '23 09:09 Driwen4356