⭐
StarAPI Documentation
  • ⭐API Information
    • ❔About Our API's
    • ⬇️Installing Our API
  • 🌟StarAPI (Spigot/Paper)
    • 📂Abilities
      • ⏳Transmition
      • 🤯Implosion
      • 🏹MultiShot
    • 📂Builders
      • 👕Armor Builder
      • 📊Bossbar Builder
      • ☄️Command Builder
      • ⚔️Item Builder
      • 🧟‍♂️Mob Builder
      • 💯Scoreboard Builder
      • 🔗Webhook Builder
      • 🔨Message Builder
      • 🏗️Actionbar Builder
    • 📂Files
      • 📃Create Files
      • 📁Create Folders
      • 📖Read Files
      • 🖊️Write Files
    • 📂Inventory Utilities
      • 💎Animated Items
      • 📖Book Content
      • 📔Book GUI
      • 🎞️Filler
      • 🪁Inventory Items
      • 📝Inventory Name
      • 💀Inventory Skulls
    • 📂Message Utilities
      • 🤖Auto Responses
      • 🎨Message Colors
    • 📂Recipes
      • ⚒️Crafting Recipes
      • 🧑‍🍳Furnace Recipes
    • 📂Timers
      • 🕙Active Timers
      • ❌Cancel Timers
      • 🕙Delayed Timers
      • 🕐Create Timers
    • 📂Misc
      • 💀Give Skulls
      • 📈Progress Bars
      • ⬛Block Placer
Powered by GitBook
On this page
  • Overview
  • Methods
  • Example
  1. StarAPI (Spigot/Paper)
  2. Timers

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

long delay = 0; // Start the task immediately
long period = 20; // Repeat every 20 ticks (1 second)
Runnable task = () -> {
    // Your task logic here
};
BukkitTask repeatingTask = Timer.timer(delay, period, task);

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).

PreviousDelayed TimersNextMisc

Last updated 1 year ago

🌟
📂
🕐