Cool Downs

Discussion in 'Plugin Development' started by BashyDaBest, Jan 21, 2015.

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

    BashyDaBest

    I was wondering if anyone could explain to me how I can use cool downs. You can also just link me to a video/website that explains it.
     
  2. Offline

    mythbusterma

    @BashyDaBest

    It kinda depends on what you wanna do.....so you should us what you've tried.
     
  3. Offline

    sirrus86

    What I do is create a HashMap for a given player (using their UUID, not the player instance) and set its value to the current time plus the cooldown you want to apply. To check if that player is still in cooldown, check to see if the current time is greater than the cooldown you set.
     
  4. Offline

    GriffinPvP

    I use this class I made: http://hastebin.com/noqemohuda.java
    You put an instance of that in a HashMap with the player's UUID as the key, and then to check if its done, just do

    Code:
     if (map.get(player.getUniqueId()).done()) {
    } 
    I also made a method to quickly get the time remaining, so if the cooldown is not done, use
    Code:
     player.sendMessage(map.get(player.getUniqueId()).getTimeRemaining()); 
    and stop the code right there.
     
  5. Offline

    BashyDaBest

    Okay thanks, I'll try them out.
     
Thread Status:
Not open for further replies.

Share This Page