Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class CooldownExample{
- public HashMap<String, Long> cooldowns = new HashMap<String, Long>();
- @Override
- public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
- int cooldownTime = 60; //le temps de cooldown en seconde
- if(cooldowns.containsKey(sender.getName())) {
- long secondsLeft = ((cooldowns.get(sender.getName())/1000)+cooldownTime) - (System.currentTimeMillis()/1000);
- if(secondsLeft>0) {
- // Cooldown pas fini
- sender.sendMessage("Vous devez attendre "+ secondsLeft +" secondes !");
- return true;
- }
- }
- cooldowns.put(sender.getName(), System.currentTimeMillis());
- //reste du code ici
- return true;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement