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

Inventory not updating

Discussion in 'Development' started by Matthew, Jan 2, 2017.

  1. Matthew

    Matthew Baby Zombie

    Messages:
    167
    GitHub:
    matthww
    Hello

    I'm making a plugin that clears the inventory when the gamemode is changed. It does clear the inventory but it's not updating it so the players still sees the items even though they are gone.

    Code:
    PHP:
        public function onGameModeChange(PlayerGameModeChangeEvent $event){
            
    $player $event->getPlayer();
                
    $event->getPlayer()->getInventory()->clearAll();
                
    $player->sendMessage("Your inventory is cleared!");
        }
    Is there a way to update the inventory so that the players won't see those ghost items?
     
  2. SkyArt4

    SkyArt4 Silverfish

    Messages:
    16
    GitHub:
    nadaree
    before that time
    PHP:
    $player->getInventory()->clearAll();
    Is it easy to see?
     
  3. Thunder33345

    Thunder33345 Moderator Staff Member

    Messages:
    2,137
    GitHub:
    Thunder33345
    get inventory -> resend contents?
    i remember there a update function along the line of resend
     
  4. robske_110 (Tim)

    robske_110 (Tim) Wither Skeleton Poggit Reviewer

    Messages:
    1,342
    GitHub:
    robske110
    As far as I remember clearAll should resend it already... let me look it up
     
  5. robske_110 (Tim)

    robske_110 (Tim) Wither Skeleton Poggit Reviewer

    Messages:
    1,342
    GitHub:
    robske110
    Oh, :facepalm:
    you have to do Inventory->sendContents(Player)
     
  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.