showTitle
Displays a title and/or subtitle to the player with customizable timing.
This extension function provides a convenient way to show titles to players using the Adventure API's Component system, with full control over timing and animation.
Receiver
The player who will see the title.
Since
1.0.0
Example usage:
// Show a simple title
player.showTitle(title = Component.text("Welcome!"))
// Show title with subtitle
player.showTitle(
title = Component.text("Game Started", NamedTextColor.GOLD),
subtitle = Component.text("Good luck!", NamedTextColor.GRAY)
)
// Show title with custom timing (quick flash)
player.showTitle(
title = Component.text("Alert!"),
fadeIn = Duration.ofMillis(100),
stay = Duration.ofMillis(500),
fadeOut = Duration.ofMillis(100)
)
// Show only subtitle with longer display time
player.showTitle(
subtitle = Component.text("Check your inventory"),
stay = Duration.ofSeconds(5)
)Parameters
The main title to display. Default is an empty component (no title). Use Component factory methods to create styled text.
The subtitle to display below the main title. Default is an empty component. Subtitles are typically smaller and appear below the main title.
The duration for the title to fade in. Default is 500 milliseconds. This controls how long the title takes to appear on screen.
The duration for the title to remain fully visible. Default is 3 seconds. This is how long the title stays at full opacity after fading in.
The duration for the title to fade out. Default is 500 milliseconds. This controls how long the title takes to disappear from screen.