-*- 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! DependencyIn 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. plugin.yml name: CooldownKits Identifying the CooldownThe 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 CooldownIn order to actually start a cool-down on a player, it isn't just identifying the cool-down. You must: cd.use(); This will change the BlockheadsAPI's config file to the time (in milliseconds) of when this was called. Check for Cooldown to be DoneTo see if the cool-down is done, simply do: if (cd.isDone()){ returns boolean Time LeftTo see how much time is left in the cooldown, use: cd.getTimeLeftInSeconds(); returns int 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: cd.getLastTimeMillis(); 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) Deleting CooldownsHere is how you delete the following things: A player from the cool-down (clear their cool-down): cd.clearPlayer(); A player from the cool-down AND the actual cool-down itself: cd.deleteAll(); Getting and Setting ManuallyHere are some other things you can do with this class: Get the delay (returns double): cd.getDelay(); Set the delay (50 as an example): cd.setDelay(50); Set the last time used manually (in milliseconds): cd.setLastTimeManually(millis); That's it!Leave a comment if you like it! Post suggestions or report errors by clicking buttons on the sidebar!
0 Comments
Leave a Reply. |
Download Blockhead's APISuggest a FeatureReport Errors-*- Features -*- |