Clear Armor

Discussion in 'Plugin Development' started by travja, May 5, 2012.

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

    travja

    How would I clear someones armor? Probably a stupid question but I can't figure it out and p.getInventory().clear(); doesn't do armor.
     
  2. Offline

    Darq

    p.getInventory().getArmourContents().setContents(null);
    Mebbe.
     
  3. Offline

    travja

    dunno
     
  4. Offline

    Darq

    Well, try?!

    Edit: no, that won't work. Le' fail. Two secs.
     
  5. Offline

    travja

    lol, ok
     
  6. Offline

    Darq

    Okay,

    Loop through the armour slots (100 - 103, I think), and setItem() to null. Like this:

    Code:
            for(int i = 100; i <= 103; i++) {
                inv.setItem(i, null);
            }
     
  7. Offline

    travja

    ....... seems tedious... maybe p.getInventory().setHelmet(null); and the chestplate and then leggings an boots?

    Just is a little confusing and isn't as visual for me.

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: May 25, 2016
  8. Offline

    Aza24

    You may have already found this but:
    Code:Java
    1. PlayerInventory inv = player.getInventory();
    2. inv.setArmorContents(new ItemStack[inv.getArmorContents().length]);
     
  9. Offline

    xGhOsTkiLLeRx

    player.getInventory().setHelmet(null);
    player.getInventory().setChestplate(null);
    player.getInventory().setLeggings(null);
    player.getInventory().setBoots(null);

    Works, too
     
  10. Offline

    TomTheDeveloper

    Code:java
    1. public void clearArmor(Player player){
    2. player.getInventory().setHelmet(null);
    3. player.getInventory().setChestplate(null);
    4. player.getInventory().setLeggings(null);
    5. player.getInventory().setBoots(null);
    6. }


    Or just make a method that you call back when you need it
     
Thread Status:
Not open for further replies.

Share This Page