showTitle

fun Player.showTitle(title: Component = Component.empty(), subtitle: Component = Component.empty(), fadeIn: Duration = Duration.ofMillis(500), stay: Duration = Duration.ofSeconds(3), fadeOut: Duration = Duration.ofMillis(500))

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

title

The main title to display. Default is an empty component (no title). Use Component factory methods to create styled text.

subtitle

The subtitle to display below the main title. Default is an empty component. Subtitles are typically smaller and appear below the main title.

fadeIn

The duration for the title to fade in. Default is 500 milliseconds. This controls how long the title takes to appear on screen.

stay

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.

fadeOut

The duration for the title to fade out. Default is 500 milliseconds. This controls how long the title takes to disappear from screen.

See also

Component

for creating styled text

Title

for more title options

for time specifications