Class CooldownUtils
java.lang.Object
ua.mcchickenstudio.opencreative.utils.CooldownUtils
CooldownUtils
This class contains utils for checking and modifying player's cooldown.-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enumRepresents type of cooldown. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic booleancheckAndSetCooldown(@NotNull org.bukkit.entity.Player player, @NotNull Group group, @NotNull CooldownUtils.CooldownType type) Checks if player has cooldown.static booleancheckAndSetCooldownWithMessage(@NotNull org.bukkit.entity.Player player, @NotNull Group group, @NotNull CooldownUtils.CooldownType type) Checks if player has cooldown.static booleancheckAndSetCooldownWithMessage(@NotNull org.bukkit.entity.Player player, @NotNull CooldownUtils.CooldownType type) Checks if player has cooldown.static voidclearPlayerCooldowns(@NotNull org.bukkit.entity.Player player) Clears all player's cooldowns.static intgetCooldown(@NotNull org.bukkit.entity.Player player, @NotNull CooldownUtils.CooldownType type) Returns player's cooldown.static longgetCooldownFromMap(@NotNull org.bukkit.entity.Player player, @NotNull CooldownUtils.CooldownType type) Returns cooldown timestamp for player, or 0 - if they don't have cooldown.static voidsetCooldown(@NotNull org.bukkit.entity.Player player, int cooldown, @NotNull CooldownUtils.CooldownType type) Sets player's cooldown.
-
Constructor Details
-
CooldownUtils
public CooldownUtils()
-
-
Method Details
-
getCooldownFromMap
public static long getCooldownFromMap(@NotNull @NotNull org.bukkit.entity.Player player, @NotNull @NotNull CooldownUtils.CooldownType type) Returns cooldown timestamp for player, or 0 - if they don't have cooldown.- Parameters:
player- player to get timestamp of cooldown.type- type of cooldown.- Returns:
- timestamp, when cooldown will be ended; or 0 - if player doesn't have cooldown.
-
setCooldown
public static void setCooldown(@NotNull @NotNull org.bukkit.entity.Player player, int cooldown, @NotNull @NotNull CooldownUtils.CooldownType type) Sets player's cooldown.- Parameters:
player- Player to set cooldown.cooldown- Cooldown to set, in seconds.type- Type of cooldown.
-
getCooldown
public static int getCooldown(@NotNull @NotNull org.bukkit.entity.Player player, @NotNull @NotNull CooldownUtils.CooldownType type) Returns player's cooldown.- Parameters:
player- Player for getting cooldown.type- Type of cooldown.- Returns:
- cooldown - Remaining time for passing cooldown, in seconds. Returns 0, if player hasn't cooldown or player has bypass.
-
checkAndSetCooldown
public static boolean checkAndSetCooldown(@NotNull @NotNull org.bukkit.entity.Player player, @NotNull @NotNull Group group, @NotNull @NotNull CooldownUtils.CooldownType type) Checks if player has cooldown. If not, sets it and returns true. If cooldown is active, returns false.- Parameters:
player- Player to check and set cooldowngroup- Group object for retrieving cooldown durationstype- Cooldown type to check/set- Returns:
- true if cooldown was not active and now set; false if still on cooldown
-
checkAndSetCooldownWithMessage
public static boolean checkAndSetCooldownWithMessage(@NotNull @NotNull org.bukkit.entity.Player player, @NotNull @NotNull Group group, @NotNull @NotNull CooldownUtils.CooldownType type) Checks if player has cooldown. If not, sets it and returns true. If cooldown is active, returns false and sends cooldown message.- Parameters:
player- Player to check and set cooldowngroup- Group object for retrieving cooldown durationstype- Cooldown type to check/set- Returns:
- true if cooldown was not active and now set; false if still on cooldown
-
checkAndSetCooldownWithMessage
public static boolean checkAndSetCooldownWithMessage(@NotNull @NotNull org.bukkit.entity.Player player, @NotNull @NotNull CooldownUtils.CooldownType type) Checks if player has cooldown. If not, sets it and returns true. If cooldown is active, returns false.- Parameters:
player- Player to check and set cooldowntype- Cooldown type to check/set- Returns:
- true if cooldown was not active and now set; false if still on cooldown
-
clearPlayerCooldowns
public static void clearPlayerCooldowns(@NotNull @NotNull org.bukkit.entity.Player player) Clears all player's cooldowns.- Parameters:
player- player to remove cooldowns.
-