Working with armor?

Discussion in 'Resources' started by Drageer, Aug 14, 2011.

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

    Drageer

    So i'm starting up a new plugin which basically makes chain armor stronger than diamond armor (This is just so I know how to work with armor I won't be releasing it :p). My question is how would i make sure that when i use getArmorContents() that the armor i'm getting is chainmail? Also would I have to use a hashmap? (I'm pretty much 100% sure I do) I've looked through the javadocs and stuff but i'm honestly not sure :S. Please explain and/or maybe provide examples? :D (I hope this doesn't sound too stupid xD)

    EDIT: Just realized i posted this in the wrong section, but not sure how to remove it D:
     
  2. Offline

    BR_

    Code:
    org.bukkit.inventory.ItemStack[] armor = player.getInventory().getArmorContents();
    if (armor[0].getType() == Material.CHAINMAIL_HELMET) {
     // player is wearing a chainmail helmet
    }
    if (armor[1].getType() == Material.CHAINMAIL_CHESTPLATE) {
     // player is wearing a chainmail chestplate
    }
    if (armor[2].getType() == Material.CHAINMAIL_LEGGINGS) {
     // player is wearing chainmail leggings
    }
    if (armor[3].getType() == Material.CHAINMAIL_BOOTS) {
     // player is wearing chainmail boots
    }
    :)
     
    Drageer likes this.
  3. Offline

    Drageer

    Haha thanks! I went on IRC and got this too. You guys are a really helpful bunch :)
     
Thread Status:
Not open for further replies.

Share This Page