Advertisement
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Player Inventory

Comments in 'Plugin Development' started by xiaoq, Apr 21, 2016.

  1. xiaoq
    Offline

    xiaoq Active Member

    Joined:
    Dec 23, 2014
    Posts:
    232
    Minecraft User:
    xiaoq
    I have a problem about getInventory
    For example:
    PHP:
    public function backupInventory($player){
          if(
    $player instanceof Player){
                   
    $inventory $player->getInventory()->getContents();
                   if(
    $player->getInventory() instanceof PlayerInventory){
                               
    $inventory2 $player->getInventory()->getContents();
                   }
            }
    }
    If I use $inventory, some time will get 'Call to a member function getContents() on null'
    How can a player instanceof Player but their inventory is not instanceof PlayerInventory?

    Main problem:
    So I want to back up player's inventory when they quit, I use PlayerQuitEvent and get their inventory and get contents, but their inventory is not instanceof player inventory, so how can I back up their inventory?

Share This Page

Advertisement