Design
Subtitles
Push timed lines of text to players with a command or the API.
A subtitle is a line of text that a server shows to a player for a few seconds, for example a narrator line, a round announcement or a quest hint. The HUD decides where and how it is drawn; the server decides what it says and when.
Add the Subtitle component
- Open the HUD in the editor and switch the toolbox to the Components tab.
- Add the Subtitle component. It places a text element at the bottom center that shows
%hud_subtitle%with a fade animation. - Restyle or move it like any other element, then deploy the project.
%hud_subtitle% is empty while no subtitle is playing, so the element shows nothing between lines.
Commands
| Command | Purpose |
|---|---|
/advancedhud subtitle <player|*> <seconds> <text> | Shows a line to one player, or to everyone with *, for the given number of seconds. |
/advancedhud subtitle clear <player|*> | Removes the current line and everything queued for that player, or for everyone. |
/advancedhud subtitle * 4 The match starts in ten seconds.
/advancedhud subtitle Steve 3 Find the blacksmith.
/advancedhud subtitle clear *Both commands require the permission advancedhud.subtitle.
Behavior
- Lines queue per player and play one after another. A new line never interrupts the one on screen.
- Text is limited to 256 characters.
- A line can only use characters supported by the font selected on the subtitle element.
Developer API
AdvancedHudApi hud = Bukkit.getServicesManager().load(AdvancedHudApi.class);
if (hud != null) {
hud.showSubtitle(player, "Find the blacksmith.", 3);
hud.clearSubtitles(player);
}| Method | Purpose |
|---|---|
showSubtitle(player, text, duration) | Queues a line for the player. |
clearSubtitles(player) | Removes the player's current and queued lines. |
See the Developer API page for the exact parameter types of these methods.