Class BukkitCooldown
- java.lang.Object
-
- org.kikikan.deadbymoonlight.cooldowns.BukkitCooldown
-
-
Constructor Summary
Constructors Constructor Description BukkitCooldown(org.bukkit.plugin.java.JavaPlugin plugin, long... values)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.util.UUID
addRunnable(java.lang.Runnable runnable, org.kikikan.deadbymoonlight.util.TimerEventType type)
Registers a Runnable to run at the specified event.org.bukkit.plugin.java.JavaPlugin
getPlugin()
Gets the JavaPlugin object which was given to it through the constructor.protected void
init(long... values)
Initializes the cooldown with the specified values.boolean
isRunning()
Checks if the Cooldown is running or not.void
off()
Turns off the cooldown.void
on()
Turns on the cooldown with the initialized values.void
on(long... values)
Turns on the cooldown with the specified values.void
removeRunnable(java.util.UUID uuid)
Removes the specified runnable using its UUID that was generated when it was added.protected void
tick()
-
-
-
Method Detail
-
on
public void on()
Turns on the cooldown with the initialized values.- Specified by:
on
in interfaceorg.kikikan.deadbymoonlight.util.Toggleable
- Throws:
java.lang.IllegalStateException
- if the cooldown wasn't initialized.
-
on
public void on(long... values)
Turns on the cooldown with the specified values. This does not initialize the cooldown. However, you can use this without it being initialized.
-
off
public void off()
Turns off the cooldown.- Specified by:
off
in interfaceorg.kikikan.deadbymoonlight.util.Toggleable
- Throws:
java.lang.IllegalStateException
- If the cooldown is on after executing this method, or another registered runnable tries to turn off the cooldown. (would result to StackOverFlowError)
-
isRunning
public final boolean isRunning()
Checks if the Cooldown is running or not.
-
init
protected void init(long... values)
Initializes the cooldown with the specified values.- Parameters:
values
- The values used for creating the BukkitTask.
First value: delay before calling therun()
method.
Second value (if exists): how frequentlyrun()
should be called.
-
getPlugin
public final org.bukkit.plugin.java.JavaPlugin getPlugin()
Gets the JavaPlugin object which was given to it through the constructor.- Returns:
- The JavaPlugin instance.
-
tick
protected void tick()
-
addRunnable
public java.util.UUID addRunnable(java.lang.Runnable runnable, org.kikikan.deadbymoonlight.util.TimerEventType type)
Registers a Runnable to run at the specified event.- Specified by:
addRunnable
in interfaceCooldown
- Parameters:
runnable
- Method to runtype
- When to run- Returns:
- The generated UUID that you will have to use for identifying the Runnable.
-
removeRunnable
public void removeRunnable(java.util.UUID uuid)
Removes the specified runnable using its UUID that was generated when it was added.- Specified by:
removeRunnable
in interfaceCooldown
- Parameters:
uuid
- The UUID which was generated when the Runnable was added.
-
-