1. The forums will be archived and moved to a read only mode in about 2 weeks (mid march).

Solved How to see someone else ender chest and inventory?

Discussion in 'Development' started by Yexeed, Aug 31, 2017.

  1. Yexeed

    Yexeed Slime

    Messages:
    76
    I wanna make a commands, one of them will show someone else inventory, and other will show someone else enderchest. If you will not write a code, can you give me a tip? Thanks in advance. Sry if my english is bad
     
  2. LCraftPE

    LCraftPE Silverfish

    Messages:
    20
    GitHub:
    LCraftPE
    Hello,
    Here is the code to see the inventory of another player, make good use of it!
    PHP:
    public function onCommand(CommandSender $senderCommand $commandstring $label, array $args) : bool
    {
        if(
    $command->getName() === "invsee")
        {
            if(!
    $sender instanceof Player || count($args) !== || ($player $this->getServer()->getPlayer($args[0])) === null) return false;
              
            
    $chest Tile::createTile("Chest"$sender->getLevel(), new CompoundTag("", [new StringTag("id""Chest"), new IntTag("x"round($sender->x)), new IntTag("y"round($sender->y) - 4), new IntTag("z"round($sender->z))]));
            
    $block Block::get(54);
            
    $block->$chest->x;
            
    $block->$chest->y;
            
    $block->$chest->z;
            
    $block->level $chest->getLevel();
            
    $block->level->sendBlocks([$sender], [$block]); // Extract from the ChestShop plugin developed by Muqsit
            
    foreach($player->getInventory()->getContents() as $item$chest->getInventory()->addItem($item);
            
    $sender->addWindow($chest->getInventory());
            return 
    true;
        }
    }
    Regarding to the code to see the inventory of player's Ender Chest, it is more complicated since it is necessary to assign the player to his EnderChest (with a Config for example...) and then use the same code by changing 2-3 stuff, I let you do!
    Keep me informed.
     
    Yexeed likes this.
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.