How to give a player item stack?

Discussion in 'Plugin Development' started by feaq16, May 12, 2013.

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

    feaq16

    Hi,
    How to give a player item stack with ":"?
    I try this code
    Code:java
    1.  
    2. ItemStack i = new ItemStack(35:1);
    3.  

    and doesn't work.
     
  2. Offline

    MP5K

    ...
    PHP:
    MaterialData stack_data = new MaterialData(35, (byte1);
    ItemStack stack stack.toItemStack(64);
    // typed on  ipad so untested!
     
  3. Offline

    avatarDr

  4. Offline

    Nova20012

    feaq16

    You could do:
    Code:JAVA
    1. Player p = (Player) sender;
    2.  
    3. ItemStack wool = new ItemStack(Material.WOOL, 1, (byte) 13);
    4. p.getInventory().addItem(new ItemStack(wool));


    Gives the player 35:13 (Dark Green Wool). You may have to add:
    Code:JAVA
    1. p.updateInventory();


    If it doesn't give you the item. This is deprecated though!

    All code:

    Code:JAVA
    1. Player p = (Player) sender;
    2.  
    3. ItemStack wool = new ItemStack(Material.WOOL, 1, (byte) 13);
    4. p.getInventory().addItem(new ItemStack (wool));
    5. p.updateInventory
     
  5. Offline

    feaq16

    work, thanks
     
Thread Status:
Not open for further replies.

Share This Page