/kit command cooldown

Discussion in 'Plugin Development' started by Rowinvd, Apr 24, 2015.

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

    Rowinvd

    How can i add a kit cooldown? ( Every 1 day )
    I also wanted to save the cooldown when i stop/reload the server.
    Like: Its 11:59, I do /kit Starter. Then when its 12:00 i'll stop the server.
    Then after 10 minutes it will turn on the server. when i do /kit Starter, it will say:
    You can do this kit again in 23 hours, and 49 minutes.
     
  2. Offline

    TehHypnoz

    To create a cooldown, store the current time, then when the user enters the command again check the time again and you should be able to calculate if the user can use the kit again. To save it, just save and load it to a config file in your onEnable/onDisable methods.
     
  3. Offline

    mine-care

    @Rowinvd i do it by using system timestamp so the time a player gets the kit, i log the System#currentTimeMills(); and when they attempt to get it again, i check if the purchase time + one day in miliseconds is less or equal to the currentTimeMills() if true they can get it again else they cant.
    Hint:
    Use TimeUnit enum to convert days/hours/minutes/seconds ect to whatever you need :- )
     
Thread Status:
Not open for further replies.

Share This Page