How can I tell when a player equips armor?

Discussion in 'Plugin Development' started by scarabcoder, Dec 28, 2013.

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

    scarabcoder

    Is there an event or something that is called when a player equips armor? I need help on this! Thanks, Scarabcoder
     
  2. Offline

    WhatAaCow

    scarabcoder Hm no event (i think), but you can test the InventoryClickEvent --> look if slot is an armor slot --> check what the slot contents are. Hope you understand :)
     
  3. Offline

    scarabcoder

    WhatAaCow Yeah, I understand. I'm trying it, and it activates, but does not de-activate, if ya see what I mean. I check if there is air in the slot, and if so it takes away speed. If there is gold boots there, it adds speed. Well, it adds speed, but does not take away.
     
  4. Offline

    WhatAaCow

    scarabcoder is it air? print it out to console on click event :)

    my idea:
    Code:java
    1. @EventHandler
    2. public void onPlayerInteract(InventoryClickEvent event) {
    3. // clear players effects ; yeah i know this will be slow but should work :)
    4. for (ItemStack itemStack : event.getWhoClicked().getInventory().getArmorContents()) {
    5. if (itemStack.getType() == Material.??) // adding speedeffect
    6. }
    7. }
     
  5. Offline

    scarabcoder

    WhatAaCow I know, but I checked if the boots were air. No luck. I checked if it was null, still didn't work!
     
  6. Offline

    xTigerRebornx

    scarabcoder Try checking if its != null, and if it is, return;, then have an else{} doing what you want to do?
     
  7. Offline

    Fluxanoia

    InventoryClickEvent - getInventory().get<ArmorType>()?
     
    WhatAaCow likes this.
  8. Offline

    Henzz

    scarabcoder
    Try using a scheduler and run it every x seconds, although this may be inefficient.
    You can also use this code for full armor check if needed be.
    http://pastebin.com/LWhmvrCu

    Might want to post your code for other devs to see.
     
  9. Offline

    JRL1004

    Henzz I think that Fluxanoia solved this. The person is looking for what the boots are and what he put returns the boots just fine. Not only that but by running it only on inventory click could prove to be much more efficientthan a scheduler (depending on the delay between checks).
     
  10. Offline

    Fluxanoia

    #OneHitWonder
     
Thread Status:
Not open for further replies.

Share This Page