BlurpCooldown

Features

  • Simple builder pattern for configuring cooldowns

  • Set cooldown duration in ticks

  • Register callbacks for when the cooldown starts and completes

  • Chain methods fluently for easy setup

  • Integrates with BlurpSchedulerfor timing

Usage

Basic Example

new BlurpCooldown()
    .cooldown(40) // 40 ticks (2 seconds)
    .onStart(() -> System.out.println("Cooldown started!"))
    .onComplete(() -> System.out.println("Cooldown finished!"))
    .start();

Chaining

You can chain the configuration methods for concise and readable code.

BlurpCooldown cooldown = new BlurpCooldown()
    .cooldown(100)
    .onStart(() -> { /* logic when cooldown starts */ })
    .onComplete(() -> { /* logic when cooldown ends */ });

cooldown.start();

API Reference

Method
Description

cooldown(int ticks)

Sets the cooldown duration in ticks. Returns the instance for chaining.

onStart(Runnable onStart)

Sets a callback to run when the cooldown starts. Returns the instance.

onComplete(Runnable onComplete)

Sets a callback to run when the cooldown completes. Returns the instance.

start()

Starts the cooldown, running onStart immediately and onComplete after the cooldown duration.

Notes

  • Cooldown duration is specified in ticks (20 ticks = 1 second in Minecraft).

  • The onStart callback runs immediately when start() is called.

  • The onComplete callback runs after the cooldown duration.

Last updated