Add an ItemStack in an inventory?

Discussion in 'Plugin Development' started by okami35, Dec 17, 2011.

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

    okami35

    Hello,
    In my last plugin, i would like to add an itemstack in a player's inventory.(like a give)
    For the moment, I just have:

    Code:
    ItemStack is = new ItemStack(id, nbre);
    Do you have any ideas?

    thank you for your help.
     
  2. Offline

    Mitsugaru

    Assuming you already have your Player object (named player for this example), the following would work:

    Code:
    HashMap<Integer, ItemStack> residual = player.getInventory().addItem(is);
    The 'residual' object contains all the items that couldn't be added to the player's inventory

    The method was in the javadocs, which I highly suggest looking over.
     
  3. Offline

    tips48

    For reference;JavaDoc link: jd.bukkit.org
     
Thread Status:
Not open for further replies.

Share This Page