New to plugins, how to do the player.setItemInHand thing?

Discussion in 'Plugin Development' started by MultiBana, Jan 6, 2012.

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

    MultiBana

    If i want to make a plugin that will give you a stone block when you write /stone, how to do it?

    I mean, player.setItemInHand(WTF TO WRITE IN HERE?);

    I tried stone, and i tried 1.
    Not working.

    Help? :)

    EDIT: And btw how to make that it gives you 1 stone, like when you pick a dropped one, that it doesnt replace your item in hand?
     
  2. Offline

    surtic

    It want a ItemStack ant not a TypId.

    player.setItemInHand( new ItemStack( Material.STICK ) );
    player.setItemInHand( new ItemStack( Material.STONE, 64));
     
  3. Offline

    number1_Master

    adding to the above, 64 would be the amount
     
  4. Offline

    MultiBana

  5. Offline

    ItsHarry

    For the picking up part, you would use addItem to add the item to your inventory
     
  6. Offline

    Father Of Time

    Ya, as stated above; I would do AddItem to their inventory, not set the item in their hand. I say this because if the person has an item in their hand (say a diamond sword) and they use your command /stone it will change the sword item into a stone, aka piss people off...

    I would either add it to the first available slot in their inventory, or so a null check on their hand first to make sure you aren't overriding what they are already holding.

    Good luck!
     
Thread Status:
Not open for further replies.

Share This Page