Solved Skill timer

Discussion in 'Plugin Development' started by sohardhun15, May 20, 2014.

Thread Status:
Not open for further replies.
  1. I want to make a skill timer. If a player use his skill it counts back. For each player i need a timer?
     
  2. sohardhun15 Not for each player no, just each player that are going to use skills.
     
  3. And how can i do it?
     
  4. Offline

    DxDy

    You store the Player (or UUID) ----> Countdown relations in a map.
     
  5. AdamQpzm
    Nothing :( I dont know where to start

    DxDy
    Like this?
    Code:java
    1. HashMap<String, BukkitRunnable> timer = new HashMap<String, BukkitRunnable>();


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

    DxDy

    Not neccessarily. It really depends on your implementation of the cooldowns. Since you mentioned "count back" I assumed you wanted coodowns as integer-values which are repeatedly decremented.
     
  7. DxDy
    It needs to count back :) But i dont know how to make it with map.
     
  8. Offline

    DxDy

    If the concept of a Map is new to you, I'd suggest you read up on it and then reconsider how to do this ;)
     
  9. i can't speak english very well, so can you write a code or an example?
     
  10. Offline

    DxDy

    No.

    What would be the point of me writing you an example (in other words doing your work)? The next time you needed it (and trust me, key-value mappings are something you're going to need very often) you'd still not be much further.

    Also, in the time of online translations, why can't you just let the engine of your choice translate it for you? Besides there are tons of tutorials on Maps online, and I bet you there is one in your language as well ;)
     
  11. DxDy
    I can use maps, but how can i set the int every second? And if it 0 then cancel the timer for THAT player.
     
  12. Offline

    DxDy

    You register a repeating timer which decrements the value every second. Buf if you're only going to use it for that, why not simply save the currentTimeMilis() in the moment of the execution and check against that each time someone actually tries to use a cooldown? That would save you the hassle of permanently updating the map ;)
     
Thread Status:
Not open for further replies.

Share This Page