pmmp / PocketMine-MP

A server software for Minecraft: Bedrock Edition in PHP
https://pmmp.io
GNU Lesser General Public License v3.0
3.27k stars 1.55k forks source link

Invmenu prob #3792

Closed HotDogMastah closed 4 years ago

HotDogMastah commented 4 years ago

Nothing seems to be happening theres no error also, the invmenu is already in the varions folder but nothing is still happening

`<?php

namespace code\villagertrade;

use pocketmine\Player;

use pocketmine\plugin\PluginBase;

use pocketmine\command\Command; use pocketmine\command\CommandSender;

use pocketmine\item\Item;

use pocketmine\event\Listener;

use muqsit\invmenu\InvMenu; use muqsit\invmenu\InvMenuHandler;

use pocketmine\inventory\transaction\action\SlotChangeAction; use muqsit\invmenu\transaction\InvMenuTransaction;

class Main extends PluginBase implements Listener {

public function onEnable(){
    if(!InvMenuHandler::isRegistered()){
        InvMenuHandler::register($this);
    }
}

 public function onCommand(CommandSender $sender, Command $cmd, string $label, array $args) : bool{
    switch($cmd->getName()){
        case "menu":
            if($sender instanceof Player){
                $menu = InvMenu::create(InvMenu::TYPE_CHEST);
                $menu->readonly();
                $inv = $menu->getInventory();
                $inv->addItem(Item::get(Item::DIAMOND));
                $menu->setListener(function(InvMenuTransaction $transaction) : InvMenuTransactionResult{
                    $player = $transaction->getPlayer();
                    $itemClicked = $transaction->getItemClicked();
                    $itemClickedWith = $transaction->getItemClickedWith();
                    $action = $transaction->getAction();
                    if($itemclicked->getid() === Item::get(Item::DIAMOND)){
                        $player->sendMessage("test");
                        $player->removeWindow($action->getInventory());

                    }
                });
                $menu->send($sender);
            }
        break;
 }
 return true;

}`

ethaniccc commented 4 years ago

if($itemclicked->getid() === Item::get(Item::DIAMOND)){ Strict comparison between an integer and an Item, yep, definitely a reason to put this as an issue on the PocketMine repo!

support[bot] commented 4 years ago

Thanks, but this issue tracker is not intended for support requests. Please read the guidelines on submitting an issue.

Docs | Discord | Forums