Class CooldownUtils

java.lang.Object
ua.mcchickenstudio.opencreative.utils.CooldownUtils

public final class CooldownUtils extends Object

CooldownUtils

This class contains utils for checking and modifying 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 cooldown
      group - Group object for retrieving cooldown durations
      type - 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 cooldown
      group - Group object for retrieving cooldown durations
      type - 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 cooldown
      type - 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.