Solved Setting Players Inventory

Discussion in 'Plugin Development' started by Digbywood, Jan 14, 2015.

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

    Digbywood

    Hey I need some help with my plugin I'm creating. I have made my own Inventory variables and I want to set the players inventory with those variables. I was hoping for something in the Bukkit API like this:
    Code:
    player.setInventory(Inventory)
    But there is nothing I could see.
    Any help?

    Whoops just found a way todo it just after I posted this:
    Code:
    for(ItemStack is: myInventory.getContents()){
        player.getInventory().addItem(is)
    I just looped through Items in inventory and added them.
    Havent tested it yet though so may not work :/

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 13, 2016
  2. Offline

    Epicdog

    Well you could save their inventory with:
    Code:
    inv.put(player.getUniqueId(), p.getInventory().getContents());
            armor.put(p.getUniqueId(), p.getInventory().getArmorContents());
    
    And then later put it back with:
    Code:
     player.getInventory().setContents(inv.get(p.getName()));
            p.getInventory().setArmorContents(armor.get(p.getName()));
     
Thread Status:
Not open for further replies.

Share This Page