[Solved] Event help

Discussion in 'Spigot Plugin Development' started by dyenxunit, Jun 5, 2015.

  1. I was wondering which event do i use to check if the player is wearing stuff with the ItemMeta "Unbreakable".
    #1 dyenxunit, Jun 5, 2015
    Last edited: Jun 5, 2015
  2. You could have a Runnable that runs every second, and get the slots for player helmet, chestplate, leggings, and boots.

    Code (Text):
    if (p.getInventory().getHelmet().getItemMeta() == [check here]) {
        // execute code
    replace getHelmet() with getChestplate(), getLeggings(), and getBoots()
  3. It depends on what you wanna do, you have to tell us more information. Like, what are you trying to do if they are wearing that armor?
  4. When they equip the armor i want an event to happen and when the armor = to null i want the event to be cancelled.
    #4 dyenxunit, Jun 6, 2015
    Last edited: Jun 6, 2015
  5. In that case, if you're not going to use the Runnable (I suggest using this because...well....read on), you are going have to check every way a player can equip armor. You can check if they click in their inventory on the armor (to equip it). Another way a player can equip armor is by right clicking on the armor while it's in their hotbar. Yet another way is by dispensers. You will have to check each time a dispenser goes off, check what item it dispenses, check what player it hit, check if they are already wearing that piece of armor, and check if the armor is Unbreakable. Please just use the Runnable.
  6. Will it lag is the question ? because all i want to do is know what event to call so it checks if the player has that armor on
  7. It will lag if you do it the hard way (second option), but if you only have the Runnable execute every second, it shouldn't lag.

    Example: I created a super smooth rave armor plugin looping through every RGB value, with no speed limit, and it doesn't lag, so running every second shouldn't do much at all. :)
  8. Sorry im still a newbie coder so i have no clue how to do that so thats why im taking the easiest route as possible
  9. If you want I can create a simple class for you to insert into your program.
  10. ty that would be great :)
  11. Tux


    Please don't spoon-feed code.
  12. I created my own class already so i wont be needing his code
    #12 dyenxunit, Jun 6, 2015
    Last edited: Jun 6, 2015
  13. I already created a new runnable task ty
  14. There are just some people who are unwilling to learn it themselves....I don't believe that dyenxunit is one of those people, but, you never know in this world....
  15. Still a newbie but still working on it i try my best not to ask people for the code
    • Agree Agree x 1
  16. People won't usually admit it, but we all started out as newbies.