Cooldown.java is a pretty easy way to make a delay before using a command/item etc. Cooldown.java provides quite a bit of flexibility. It also gives you the ability to specify what happens after the cooldown.
Cooldown will not save after restart.
How to use it
After 1.8-beta cooldown class is using ticks in cooldownTime argument, not seconds.
Declare Cooldown variable.
private Cooldown<Player> cooldown = new Cooldown<>();
// You also can use string, UUID and etc. for T arg.
Adding cooldown
// Just add cooldown
cooldown.addNewCooldown(player, cooldownTime);
// Rewrite cooldown if exists
cooldown.addNewCooldown(player, cooldownTime, true);
// Execute runnable after cooldown is complete.
cooldown.addNewCooldown(player, cooldownTime, new Runnable());
// Rewirite cooldown if exists and execute runnable after cooldown is complete.
cooldown.addNewCooldown(player, cooldownTime, new Runnable(), true);
Removing and checking cooldowns
cooldown.containCooldown(player); // Check for cooldown
cooldown.removeCooldown(player); // Remove cooldown
CooldownTask
CooldownTask class is a simple implementation of BukkitRunnable with some QOL improvements.
Example
Cooldown<T> cooldown = new Cooldown<T>(); // replace T with class like player or etc.
cooldown.addCooldownTask(T, 60); // 60 ticks = 3 seconds
And done.
So whats special in this class? Basicly you can change task ticks left and runnable when task is already running. Also you can get ticks left via getTicksLeft method. But Cooldown class is using BukkitRunnable class in his map, so you need to cast BukkitRunnable to CooldownTask class.