# Reference

Libraries and utilities exposed to the script environment.

Main script class available in the global scope of each script. Provides access to various utilities.

Variables
--- Returns the name of the script.
script.name: string

--- Returns the script's Logger instance.
script.logger: Logger
Functions
--- Registers a server command that players and console can execute.
--  @param handler The command handler function
--  @param metadata The command metadata table
script:registerCommand(handler: (sender: CommandSender, args: table) -> void, metadata: table): void

--- Registers an event listener.
--  @param event The event class
--  @param handler The event handler function
script:registerListener(event: string, handler: (event: Event) -> void): void

Provides methods to schedule and manage tasks. It supports both synchronous and asynchronous task execution with various timing options.

Functions
--- Schedules a task to run on the next tick.
--  @param handler The task function to execute
scheduler:run(handler: (BukkitRunnable) -> void): BukkitTask

--- Schedules an asynchronous task to run on the next tick.
--  @param handler The task function to execute
scheduler:runAsync(handler: (BukkitRunnable) -> void): BukkitTask

--- Schedules a task to run after a delay (in ticks).
--  @param handler The task function to execute
--  @param delay Delay in ticks before execution
scheduler:runDelayed(handler: (BukkitRunnable) -> void, delay: number): BukkitTask

--- Schedules an asynchronous task to run after a delay (in ticks).
--  @param handler The task function to execute
--  @param delay Delay in ticks before execution
scheduler:runDelayedAsync(handler: (BukkitRunnable) -> void, delay: number): BukkitTask

--- Schedules a repeating task.
--  @param handler The task function to execute
--  @param delay Delay in ticks before first execution
--  @param period Interval in ticks between executions
scheduler:runRepeating(handler: (BukkitRunnable) -> void, delay: number, period: number): BukkitTask

--- Schedules an asynchronous repeating task.
--  @param handler The task function to execute
--  @param delay Delay in ticks before first execution
--  @param period Interval in ticks between executions
scheduler:runRepeatingAsync(handler: (BukkitRunnable) -> void, delay: number, period: number): BukkitTask

--- Cancels the provided task.
--  @param taskId The id of the tas to cancel
--  @param runnable The runnable instance of the task to cancel
--  @param task The task to cancel
scheduler:cancel(taskId: number | runnable: BukkitRunnable | task: BukkitTask): void