Skip to content
This repository was archived by the owner on Apr 14, 2025. It is now read-only.

Latest commit

 

History

History
380 lines (240 loc) · 11.8 KB

File metadata and controls

380 lines (240 loc) · 11.8 KB

LuaLink Documentation

The project is in an experimental state, so is the documentation - expect things to change quite often.

For new Lua users, this community-contributed documentation may help you to get started.


Navigation


Reference

Full reference of variables and functions provided by LuaLink.


Click the link to view LuaScript class in the source code.


script: LuaScript

   Description
     Returns LuaScript instance representing a Lua script, granting access to its core functions.


script.logger: LuaLogger

   Description
     Returns the LuaLogger instance of LuaLink plugin.


script.getServer(): Server

   Description
     Returns the Server instance.


script.onLoad(callback: () -> void): void

   Description
     Called after the script has been successfully loaded.

   Parameters
     callback - function to be executed.


script.onUnload(callback: () -> void): void

   Description
     Called before the script is attempted to be unloaded.

   Parameters
     callback - function to be executed.


script.hook(event: string, callback: (event: Event) -> void): void

   Description
     Registers an event hook for specified event class.

   Parameters
     event - the name of the event class to hook into.
     callback - function to execute when the event occurs.


script.registerSimpleCommand(callback: (sender: CommandSender, args: table) -> void, metadata: table): void

   Description
     Registers command with specified callback and metadata to the server.

   Parameters
     callback - function to be executed when command is run.
     metadata - metadata for the command.

   Metadata
     name - primary name of the command.
     permission - optional access permission of the command.
     usage - optional usage of the command.
     description - optional description of the command.
     tabComplete - optional function to be executed for tab-completion.



Click the link to view LuaUtils class in the source code.


utils: LuaUtils

   Description
     Returns LuaUtils instance, granting access to various utility functions.


utils.instanceOf(object: ?, class: string): boolean

   Description
     Checks if an object is an instance of a specified class.

   Parameters
     object - the object to check.
     class - the name of the class to check against.



Click the link to view LuaLogger class in the source code.


logger: LuaLogger

   Description
     Returns LuaLogger instance, granting access to various logging functions.


logger.info(message: string): void

   Description
     Logs an informational message to the console.

   Parameters
     message - the message to log as an information.


logger.warning(message: string): void

   Description
     Logs a warning message to the console.

   Parameters
     message - the message to log as a warning.


logger.severe(message: string): void

   Description
     Logs a severe (error) message to the console.

   Parameters
     message - the message to log as an error.



Click the link to view PrintOverride class in the source code.


print(message: string): void

   Description
     Logs a message to the plugin logger. Override for built-in print function.

   Parameters
     message - the message to log.



Click the link to view LuaScheduler class in the source code.


scheduler: LuaScheduler

   Description
     Returns LuaScheduler instance, granting access to scheduler-related functions.


scheduler.run(callback: () -> void): void

   Description
     Schedules task to be run on the next tick.

   Parameters
     callback - function to be executed.


scheduler.runAsync(callback: () -> void): void

   Description
     Schedules asynchronous task to be run on the next tick.

   Parameters
     callback - function to be executed.


scheduler.runDelayed(callback: (task: BukkitTask) -> void, delay: number): BukkitTask

   Description
     Schedules task to be run after delay ticks has passed.

   Parameters
     callback - function to be executed.
     delay - delay measured in ticks.


scheduler.runDelayedAsync(callback: (task: BukkitTask) -> void, delay: number): BukkitTask

   Description
     Schedules asynchronous task to be run after delay ticks has passed.

   Parameters
     callback - function to be executed.
     delay - delay measured in ticks.


scheduler.runRepeating(callback: (task: BukkitTask) -> void, delay: number, period: number): BukkitTask

   Description
     Schedules task to be run after delay ticks has passed, and repeated every delay ticks.

   Parameters
     callback - function to be executed.
     delay - delay measured in ticks.
     period - period of task re-occurrence measured in ticks.


scheduler.runRepeatingAsync(callback: (task: BukkitTask) -> void, delay: number, period: number): BukkitTask

   Description
     Schedules asynchronous task to be run after delay ticks has passed, and repeated every delay ticks.

   Parameters
     callback - function to be executed.
     delay - delay measured in ticks.
     period - period of task re-occurrence measured in ticks.


scheduler.cancelTask(taskId: number): void

   Description
     Cancels a currently running (or scheduled) Bukkit task.

   Parameters
     taskId - the Bukkit task id.



Click the link to view LuaEnumWrapper class in the source code.


enums: LuaEnumWrapper

   Description
     Returns LuaEnumWrapper instance, granting access to commonly-used Bukkit enums.


enums.EntityType: LuaEnum<EntityType>

   Description
     Provides access to Bukkit's EntityType enum wrapped as LuaEnum.


enums.Material: LuaEnum<Material>

   Description
     Provides access to Bukkit's Material enum wrapped as LuaEnum.


enums.Sound: LuaEnum<Sound>

   Description
     Provides access to Bukkit's Sound enum wrapped as LuaEnum.



Click the link to view LuaEnum<E> class in the source code.


(LuaEnum<E>).get(name: string): E

   Description
     Returns enum instance of E from provided case-sensitive name, or nil if not found.

   Parameters
     name - case-sensitive name of the enum constant.


(LuaEnum<E>).valueOf(name: string): E

   Description
     Returns enum instance of E from provided case-sensitive name, or nil if not found.

   Parameters
     name - case-sensitive name of the enum constant.


(LuaEnum<E>).values(): table

   Description
     Returns all enum constants defined in this enum class.



Click the link to view LuaImport class in the source code.


import(classname: string): ?

   Description
     Returns a reference to the imported Java/Kotlin class. This function is available globally.

   Parameters
     classname - fully-qualified name of the Java/Kotlin class to import.



Click the link to view LuaAddons class in the source code.


addons: LuaAddons

   Description
     Returns LuaAddons instance, providing a way to get instance of loaded addon.


addons.get(name: string): ?

   Description
     Returns instance of addon with specified name. Throws IllegalArgumentException if not found.

   Parameters
     name - case-sensitive name of the addon.