How to get item ID and item data?

Discussion in 'Plugin Development' started by dup9let, Jan 26, 2014.

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

    dup9let

    Hello , i have a problem , to get a item data....
    Like this: 5:3 (Jungle wooden plank) or 351:14 .. And others items...

    I can get only the full name like this : GOLDEN_APPLE(1)
    Code:
    Code:java
    1. MaterialData data = (p.getInventory()).getItemInHand().getData();


    How to get only: 322:1 not GOLDEN_APPLE(1) - for example..

    Someone ? :oops:

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

    ThunderWaffeMC

    .getId() ?

    Example:

    Material.APPLE.getId();
    event.getBlock().getId();
     
  3. Offline

    dup9let

    i can't use " getId " ! Only getTypeId , but it will not show me the item data! It will show me only 322 not 322:1
     
  4. Offline

    Brixishuge

  5. Offline

    DeGambler

    dup9let Should work fine:
    Code:java
    1.  
    2. @SuppressWarnings("deprecation")
    3. public void getStackData(Player player) {
    4. int itemTypeId = player.getItemInHand().getTypeId();
    5. short itemDur = player.getItemInHand().getDurability();
    6. player.sendMessage("Item info: " + itemTypeId + ":" + itemDur);
    7. return;
    8. }
     
    dup9let likes this.
  6. Offline

    dup9let



    Big , Big Thank you!!! It works! :D Nice ... I never not imagine try to use getDurability ... ;d CAN CLOSE THIS TOPIC!
     
Thread Status:
Not open for further replies.

Share This Page