Event that is when you put on armor?

Discussion in 'Plugin Development' started by isleepzzz, Nov 6, 2013.

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

    isleepzzz

    Hello bukkit developer! :)

    I want to know, what is the event that is called when a player tries to put on armor (to wear)?

    My idea: I want to make it check the lore of the item and if it has "Req. Level: X" then check the player's level and if its X or higher, wear it, otherwise don't wear it.
     
  2. Offline

    Ebbez

    isleepzzz Maybe you can also do:
    Code:java
    1. public void onArmorInteract(PlayerInteractEvent e){
    2. Player player = e.getPlayer();
    3. if(player.getItemInHand().getType() == Material.IRON_CHESTPLATE){
    4. // Bla bla bla
    5. }
    6. }
     
  3. Offline

    isleepzzz

    Thank you:)

    Uh oh!
    How do I get the item that I am attempting to wear?

    Should I do:
    Code:java
    1. ItemStack i = ((Player) p).getPlayer().getItemOnCursor();

    or is there an actual thing for it?

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

    hanahouhanah

    I don't think there is an actual event for this.
    What you can do, however, is check when a player's inventory is closed and check if their armor is nonexistent (I think you can use "air"), or if it's something else.
     
  5. Offline

    isleepzzz


    Ahh ok, what is the event for the player closing his inventory?
     
  6. Offline

    hanahouhanah

    I believe it's "InventoryCloseEvent"
    You should also check if the inventory being closed is a player inventory rather than a chest/doublechest/furnace, etc.
     
Thread Status:
Not open for further replies.

Share This Page