The Adventure API provides Lua scripts with access to the Kyori Adventure library for advanced text formatting, boss bars, titles, action bars, sounds, and more in Minecraft.
The API is accessed via the global AdventureApi table in Lua scripts.
Sends a colored text message to an audience.
Syntax:
AdventureApi:sendColored(audience, color, message, [decoration])Parameters:
audience(userdata): The target audience (e.g., player, console)color(string): Color name (case-insensitive). Valid colors:red,green,blue,yellow,white,black,dark_red,dark_green,dark_blue,dark_aqua,dark_purple,gold,gray,dark_gray,aqua,light_purplemessage(string): The text message to senddecoration(string, optional): Text decoration. Valid values:bold,italic,underline/underlined,strikethrough/strike,obfuscated/magic
Example:
AdventureApi:sendColored(sender, "red", "This is red text", "bold")
AdventureApi:sendColored(sender, "green", "This is green text")Sends a clickable link message to an audience.
Syntax:
AdventureApi:sendLink(audience, message, url, [color], [decoration])Parameters:
audience(userdata): The target audiencemessage(string): The text to displayurl(string): The URL to open when clickedcolor(string, optional): Color name (defaults to white)decoration(string, optional): Text decoration
Example:
AdventureApi:sendLink(sender, "Click here for Google", "https://google.com", "blue", "underline")Sends a message with hover text to an audience.
Syntax:
AdventureApi:sendHover(audience, message, hoverText, [color], [decoration])Parameters:
audience(userdata): The target audiencemessage(string): The text to displayhoverText(string): The text to show when hoveringcolor(string, optional): Color name (defaults to white)decoration(string, optional): Text decoration
Example:
AdventureApi:sendHover(sender, "Hover over me!", "This is hover text", "yellow", "bold")Sends a message formatted with MiniMessage syntax.
Syntax:
AdventureApi:sendMiniMessage(audience, miniMessageString)Parameters:
audience(userdata): The target audienceminiMessageString(string): MiniMessage formatted string (e.g.,<red>text</red>,<gradient:gold:white>text</gradient>)
Example:
AdventureApi:sendMiniMessage(sender, "<red>Red mini message</red> and <bold>bold text</bold>")
AdventureApi:sendMiniMessage(sender, "<gradient:gold:white>Gradient text!</gradient>")Sends a translatable message using Minecraft's translation keys.
Syntax:
AdventureApi:sendTranslatable(audience, translationKey, [args...])Parameters:
audience(userdata): The target audiencetranslationKey(string): Minecraft translation key (e.g.,block.minecraft.stone)args...(string, optional): Arguments to substitute into the translation
Example:
AdventureApi:sendTranslatable(sender, "block.minecraft.stone")
AdventureApi:sendTranslatable(sender, "death.fell.accident.generic", "Player")Sends a message with insertion text (shift-click to insert into chat).
Syntax:
AdventureApi:sendInsertion(audience, message, insertionText, [color], [decoration])Parameters:
audience(userdata): The target audiencemessage(string): The text to displayinsertionText(string): The text to insert when shift-clickedcolor(string, optional): Color name (defaults to white)decoration(string, optional): Text decoration
Example:
AdventureApi:sendInsertion(sender, "Shift-click me!", "inserted_text", "aqua", "italic")Sends a title and subtitle to an audience.
Syntax:
AdventureApi:sendTitle(audience, title, [subtitle], [fadeIn], [stay], [fadeOut])Parameters:
audience(userdata): The target audiencetitle(string): The main title textsubtitle(string, optional): The subtitle textfadeIn(number, optional): Fade-in duration in milliseconds (must be used with stay)stay(number, optional): Stay duration in milliseconds (must be used with fadeIn)fadeOut(number, optional): Fade-out duration in milliseconds (defaults to 1000)
Example:
AdventureApi:sendTitle(sender, "Main Title", "Subtitle text")
AdventureApi:sendTitle(sender, "Timed Title", "With timing", 500, 1500, 500)Sends a message to the action bar.
Syntax:
AdventureApi:sendActionBar(audience, message)Parameters:
audience(userdata): The target audiencemessage(string): The message to display
Example:
AdventureApi:sendActionBar(sender, "This is an action bar message")Creates and displays a boss bar for an audience.
Syntax:
local bossBar = AdventureApi:sendBossBar(audience, title, progress, [color])Parameters:
audience(userdata): The target audiencetitle(string): The boss bar titleprogress(number): Progress value between 0.0 and 1.0 (clamped if out of range)color(string, optional): Color name (defaults to pink). Maps string color names to Bukkit BarColor enum values: red→RED, green→GREEN, blue→BLUE, yellow→YELLOW, white→WHITE, all other colors→PINK
Returns:
bossBar(userdata): The BossBar object (use withhideBossBar)
Example:
local bossBar = AdventureApi:sendBossBar(sender, "Test Boss Bar", 0.5, "red")Hides a previously shown boss bar.
Syntax:
AdventureApi:hideBossBar(audience, bossBar)Parameters:
audience(userdata): The target audiencebossBar(userdata): The BossBar object returned bysendBossBar
Example:
local bossBar = AdventureApi:sendBossBar(sender, "Test Boss Bar", 0.5, "red")
-- ... later ...
AdventureApi:hideBossBar(sender, bossBar)Plays a sound for an audience.
Syntax:
AdventureApi:playSound(audience, soundKey, [volume], [pitch])Parameters:
audience(userdata): The target audiencesoundKey(string): Minecraft sound key (e.g.,entity.player.levelup,block.note_block.pling)volume(number, optional): Volume (defaults to 1.0)pitch(number, optional): Pitch (defaults to 1.0)
Example:
AdventureApi:playSound(sender, "entity.player.levelup", 1.0, 1.0)
AdventureApi:playSound(sender, "block.note_block.pling", 0.5, 2.0)Parses and sends a legacy format string (using & color codes).
Syntax:
AdventureApi:parseLegacy(audience, legacyString)Parameters:
audience(userdata): The target audiencelegacyString(string): Legacy format string with&color codes (e.g.,&cRed &lBold)
Color Codes:
&0- Black&1- Dark Blue&2- Dark Green&3- Dark Aqua&4- Dark Red&5- Dark Purple&6- Gold&7- Gray&8- Dark Gray&9- Blue&a- Green&b- Aqua&c- Red&d- Light Purple&e- Yellow&f- White&l- Bold&o- Italic&n- Underline&m- Strikethrough&k- Obfuscated&r- Reset
Example:
AdventureApi:parseLegacy(sender, "&cRed &lBold &eYellow &rReset")Joins multiple text strings with a separator and sends them.
Syntax:
AdventureApi:joinComponents(audience, separator, message1, message2, ...)Parameters:
audience(userdata): The target audienceseparator(string): The separator text between messagesmessage1, message2, ...(string): The messages to join
Example:
AdventureApi:joinComponents(sender, " | ", "First", "Second", "Third", "Fourth")Builds a text component object for later use.
Syntax:
local component = AdventureApi:buildComponent(text, [color], [decoration])Parameters:
text(string): The text contentcolor(string, optional): Color name (defaults to white)decoration(string, optional): Text decoration
Returns:
component(userdata): A Component object (for advanced use with custom Adventure API extensions)
Example:
local component = AdventureApi:buildComponent("Custom component", "light_purple", "bold")Parses a MiniMessage string and returns a Component object (without sending it).
Syntax:
local component = AdventureApi:parseMiniMessage(miniMessageString)Parameters:
miniMessageString(string): MiniMessage formatted string (e.g.,<red>text</red>,<gradient:gold:white>text</gradient>)
Returns:
component(userdata): A Component object
Example:
local component = AdventureApi:parseMiniMessage("<red>Red text</red>")
-- Use the component later with other APIs- All color names are case-insensitive
- Decoration names support aliases:
underline/underlined,strikethrough/strike,obfuscated/magic - Boss bars must be manually hidden using
hideBossBarto prevent resource leaks - Invalid colors/decorations will log a warning and fall back to defaults