Question How to store player inventory to give it to a player later

Discussion in 'Bukkit Help' started by L3N, Jun 3, 2015.

Thread Status:
Not open for further replies.
  1. Offline

    L3N

    So I'm making a register plugin and I wanna store a player inventory and clear it then when the player logs in it gives the items back to the player.
    I did this but doesn't work..

    HashMap<Player, ItemStack[]> ivvv = new HashMap<Player, ItemStack[]>();
    ItemStack[] inven;

    public void saveInventory(Player p){
    inven = new ItemStack[p.getInventory().getSize()];
    for(int i=0;i>=p.getInventory().getSize();i++){
    inven = p.getInventory().getItem(i);
    }
    ivvv.put(p, inven);
    p.getInventory().clear();
    }

    public void restoreInventory(Player p){
    for(int i=0;i>=p.getInventory().getSize();i++){
    p.getInventory().addItem(ivvv.get(p));
    }
    }
     
  2. Offline

    Googlelover1234

  3. Offline

    L3N

Thread Status:
Not open for further replies.

Share This Page