Lesson 6 of 13 · 18m
Text Is a Component: Adventure and MiniMessage
Component trees, MiniMessage for admin-written text, audiences, and why § codes are legacy plumbing.
§aHello is not a string. It is a formatting protocol smuggled through chars, and it has been retired. Paper ships Kyori's Adventure library natively, and every modern text surface — chat, kick messages, item names, tab lists, boss bars — is a net.kyori.adventure.text.Component. The ChatColor enum and § section signs still work; they are compatibility plumbing, not an API. New code speaks components.
Building components
Component msg = Component.text("Kicked: ")
.color(NamedTextColor.RED)
.append(Component.text(reason, NamedTextColor.WHITE))
.hoverEvent(HoverEvent.showText(Component.text("Appeal in /discord")))
.clickEvent(ClickEvent.runCommand("/discord"));
player.sendMessage(msg);
player.sendActionBar(Component.text("3 hearts", NamedTextColor.DARK_RED));
player.sendTitlePart(TitlePart.TITLE, Component.text("You died"));Style lives on the component, not in an escape code: .color(...), .decoration(TextDecoration.BOLD, true), hover and click events attached per component. A Component is a tree — children inherit and override style — and Paper renders it per player, including per-player localization via Component.translatable("key", args) when you ship language files.
MiniMessage for human-written text
When the text comes from a config file or an admin, hand them MiniMessage instead of & codes:
MiniMessage mm = MiniMessage.miniMessage();
Component welcome = mm.deserialize(
"<gradient:#ff0000:#0000ff>Welcome back, <player>!</gradient>",
Placeholder.unparsed("player", player.getName()));<red>, <#1a2b3c>, <bold>, <click:run_command:/spawn>, <hover:show_text:'...'>, <gradient> — a readable tag language designed for exactly this job. Admins write MiniMessage in messages.yml; you deserialize once at load and cache the components.
Two footguns, both real. First, Placeholder.unparsed — not Placeholder.component or raw string substitution — inserts the player's name as literal text. String-replacing a name into markup means a player named <red>griefer injects tags into your template. Second, tags like <click:run_command> execute as the player who clicks: never deserialize untrusted input through MiniMessage. Player-supplied strings go through Component.text(...), full stop.
Placeholder.component("name", Component.text(...)) is the variant for substituting a styled component into a template — the right tool when the placeholder carries its own color or hover, wrong for raw names.
MiniMessage also runs the other direction: mm.serialize(component) renders a built component back to tag markup — the trick that lets messages.yml round-trip text a player clicked through.
Audiences, not sendMessage(String)
player.sendMessage("a string") is the deprecated legacy path. The modern call sits on an Audience: player.sendMessage(Component), sender.sendActionBar(...), server.broadcast(component). Audience covers players, console, and broadcast groups, so one component renders correctly everywhere — including boss bars (player.showBossBar(...)) and the player list header/footer.
ClickEvent covers more than runCommand: suggestCommand fills the player's chat box, openUrl opens a link after the client confirms, copyToClipboard drops text on the clipboard, and changePage drives book UIs — all running as the clicking player, never as you. For lists of components — online admins, parsed arguments — Component.join(JoinConfiguration.separator(Component.text(", ")), parts) flattens them the way String.join does strings.
Titles, boss bars, and the tab list
The surfaces nobody expects to be components all are. player.sendTitlePart(TitlePart.TIMES, TitleTimes.times(...)) controls fade and hold; player.showBossBar(BossBar.bossBar(component, progress, color, overlay)) builds the bar; player.sendPlayerListHeaderAndFooter(header, footer) styles the tab list. All three take components — there is no sendTitle(String) worth using anymore.
Migrating old content is one call: LegacyComponentSerializer.legacySection().deserialize("§aold text"), or legacyAmpersand() for &-style configs. Run it at load on legacy values, cache the result, never emit raw § again.
The trap that bites at scale is deserializing per send. mm.deserialize(configLine) inside a listener re-parses the markup for every player, every event. Parse once in onEnable, store the Component, and player.sendMessage(cached) — the per-player work becomes a field read, which is the difference between a plugin that matters in the profiler and one that doesn't.
Field notes
NamedTextColorcovers the classic 16 colors;TextColor.color(0xRRGGBB)covers the rest.AsyncChatEvent'srenderer()is where chat formatting belongs — reshape the rendered message there, not by mutating the event's stored text.player.kick(Component)renders on the disconnect screen; a kicked player's screen is one more text surface worth getting right.- Persist components with
GsonComponentSerializer.gson()— the JSON tree keeps clicks, hovers, and colors that plain text drops. player.locale()plusComponent.translatableis the honest i18n path; hardcoded English is a choice, not a default.
Was this lesson helpful?
Keep reading
Related articles from the SudoSecurity blog.
Bukkit, Spigot, Paper, Folia: What You're Actually Running
There is a fifteen-year fork tree underneath every Minecraft server, and most admins copy a jar without knowing what's in it. Here's the whole chain, with the code — including the config key most DAB guides get wrong.
A Minecraft Mod Is a Program. In 2026, Attackers Started Acting Like It.
A Minecraft mod is a Java program that runs with your account's full permissions, and nothing in the game checks what it does.
Minecraft 26.3 Turned the Whitelist On. Your Server Probably Didn't Notice.
A fresh Minecraft 26.3 server now ships with white-list=true, so new servers are closed to strangers from the first start. Existing servers that upgraded kept their old value, which for most of them means still open.
Your Minecraft Server Isn't Slow, It's Misconfigured
Can't keep up! is not a hardware message. It's the server telling you a tick took longer than 50ms, and almost every cause is a default nobody changed. Here's what actually moves MSPT, with the flags that are now wrong and the setting that isn't where every guide says it is.