🕐Create Timers

Create a timer

Overview

The Timer class provides a utility for creating and running repeating tasks in Bukkit.

Methods

timer

public static BukkitTask timer(long delay, long period, final Runnable task)

Creates and starts a repeating timer task with a specified delay and period.

Parameters

  • delay: The delay in server ticks before the task should start.

  • period: The interval in server ticks between consecutive executions of the task.

  • task: The task to be executed repeatedly.

Returns

  • Returns the BukkitTask representing the scheduled repeating task.

Usage

  1. Call the timer method and pass the delay, period, and task to be executed as parameters.

Example

In this example, we create and start a repeating timer task using the timer method. The task will start immediately and repeat every 20 ticks (1 second).

Last updated