Solved What object to use getColor() on for leather armour?

Discussion in 'Plugin Development' started by GusGold, May 21, 2013.

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

    GusGold

    I am trying to return the colour of the leather armour that the player is wearing. I have the ItemStack[] of their armour contents, but can not for the life of me find how to return the color of that armour.

    The 1.4.7 R1 JavaDocs lists the getColor() method, but on what object do I use it on?

    Context of code:
    Code:
    ItemStack[] armourInventory = attackedPlayer.getInventory().getArmorContents();
    for (ItemStack armourPiece:armourInventory){
        //Check if the armour is a certain color
        //Do accordingly...
    }
    
     
  2. Offline

    Rocoty

    Code:
    ((LeatherItemMeta) armourPiece.getItemMeta()).getColor();
    Might be good to do a check before casting that
     
  3. Offline

    GusGold

    Alright, thanks for that. I will check it soon. Also, I am checking the armour is leather, I just omitted it to keep the post shortish :)

    Yep, that works. Thanks a bunch :)

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 1, 2016
Thread Status:
Not open for further replies.

Share This Page