Question

Discussion in 'Spigot Help' started by Cuulv, Apr 25, 2017.

  1. I was wondering how to set a timer so a player can only use a command every 45 seconds. I tried importing java.util.Timer but I cannot figure it out quite frankly.
     
  2. You could put the player's name in a HashMap, along with the time the player executed the command.
    1. When the command is called, do a check to see if the player is in the HashMap.
    2. If true, check if the time the player has been in the HashMap has been for 45 seconds or less.
      • If true, the player must wait until after 45 seconds has passed for the command execute.
    3. Otherwise, execute the command, and add/update the HashMap entry for the player's name.
    -Jesse
     
  3. How would I do that, do you have an example?
     
  4. There are many tutorials on youtube just search spigot cooldown tutorial