public class CooldownManager {
public static HashMap<String, Double> cooldowns = new HashMap<>();
public static void setCooldown(String player, int time) {
double delay = System.currentTimeMillis() + time;
cooldowns.put(player, delay);
}
public static String getCooldown(String player) {
return String.format("%.1f", (cooldowns.get(player) - System.currentTimeMillis()) / 1000);
}
public static boolean hasCooldown(String player) {
if(!cooldowns.containsKey(player) || cooldowns.get(player) <= System.currentTimeMillis()) {
cooldowns.remove(player);
return false;
}
return true;
}
}