-*- Cooldown -*-
Cool downs are mostly essential in kit plugins! You can add them to anything! Commands, other features, etc. Instead of having to create the cool down yourself, here is an easier way to do it!
In order to use this plugin, you probably want to add BlockheadsAPI into the dependencies of your plugin, so people don't end up getting errors about a plugin not existing.
Identifying the Cooldown
The thing about this plugin's cool-down is that it does not have a cool-down per each "Cooldown c = new Cooldown()." Instead, it uses the configuration file, along with names. So every time you want to access the cool-down, you would use:
Cooldown cd = new Cooldown(player, "name", 50.0);
Basically, you aren't really creating a new cool-down. You are just loading the cool-down from the name. In this case, you are loading the cool-down named name. The cool down has a 50 second delay, as you can see (meaning that you have to wait 50 seconds before the cool-down wears off). player is just the Player who the cool-down is operating upon.
Starting the Cooldown
In order to actually start a cool-down on a player, it isn't just identifying the cool-down. You must:
This will change the BlockheadsAPI's config file to the time (in milliseconds) of when this was called.
Check for Cooldown to be Done
To see if the cool-down is done, simply do:
To see how much time is left in the cooldown, use:
If you don't want it to just output seconds, and want it to be organized by day, week, hour, minute, etc: Click here to learn how to use BlockheadsAPI's TimeFormatter.
Last Time (no need to use)
You can see the last time players used the kit (time is in milliseconds) by using this:
first one returns long
second one returns int
You probably won't need to do this. If you want to see how long ago a person used the thing you have the cool-down set for, you could simply do some math like this (example):
int delay = 50;
(subtracting the time left from the actual delay)
Here is how you delete the following things:
A player from the cool-down (clear their cool-down):
A player from the cool-down AND the actual cool-down itself:
Getting and Setting Manually
Here are some other things you can do with this class:
Get the delay (returns double):
Set the delay (50 as an example):
Set the last time used manually (in milliseconds):
Leave a comment if you like it! Post suggestions or report errors by clicking buttons on the sidebar!