Solved Check Amor equip/unequip

Discussion in 'Spigot Plugin Development' started by enesmelda, Mar 27, 2020.

  1. My Goal:
    On armor equip with certain Lore,player gets extra max health and on unequip loses that health.

    Now,the lore part and add health part is no problem.My problem is the event.How do I check if a player equips a certain Armor,or unequips it.
    The Event Armorequip is not working and its hard to imagine that I"d actually had to do it for every single Action,that can equip an armor(right click,drag/...)

    Is there a solution?
  2. Choco


    A better alternative would be to use an attribute modifier for this. There's one to modify the maximum health of an entity.
    • Agree Agree x 2
    • Like Like x 1
    • Like Like x 1
  3. This has been asked like a hundred times already, use the search function. There are also multiple libs available to assist you with that (like this).
    • Like Like x 1
  4. Ok thank you,I will look into this!

    Ty,will look into this :)
    #5 enesmelda, Mar 27, 2020
    Last edited by a moderator: Mar 28, 2020
  5. I mean, this can work but it probably is not the most efficient way.
    Code (Text):

    p.getInventory().getArmorContents(); //gives a list you can loop through

    p.getInventory().getBoots(); //gets the Player's boots
    p.getInventory().getChestplate(); //gets the Player's Chestplate
    p.getInventory().getLeggings();//gets the Player's Leggings

    ItemStack ist = p.getInventory().getHelmet();//gets the Player's Helmet
    if(ist.getItemMeta().getLore()... //getLore is an ArrayList, meaning each row in the lore is a new value in the list. SO I would make a loop.
    Hopefully this helps :D
    #6 jamesd5, Mar 28, 2020
    Last edited: Mar 28, 2020
    • Useful Useful x 1
  6. Forgot to mark as solved.I just decided to use the lib.Had a few problems since I didnt know how to make the dependencies in the plugin.yml but got it working.Still thanks