"42/67", "63%", or "||||||------". Players pick their preferred format in the /npb UI, and NameplateBuilder tells your code which one they chose.
How It Works
There are three parts:- Register variant names - Tell the UI what formats are available
- Handle the variant index - Return the right format in your resolver (or push the right text manually)
- NameplateBuilder handles the rest - The UI shows a format picker, saves the player’s choice, and passes the selected index to your code
Step 1: Register Variant Names
CalldefineVariants() after define() in your setup() method. Pass a list of human-readable names for each format:
Variant names with examples
You can include an example in parentheses. The UI extracts it and shows it as a preview:Step 2: Handle the Variant Index
With Resolvers
ThevariantIndex parameter tells you which format the player selected. Use a switch to return the right text:
default case handles index 0 (the default format) and any unexpected index.
With Manual Text
If you’re usingsetText() instead of a resolver, push each variant using suffixed keys:
"health.2". If it exists, that text is used. If it’s missing, it falls back to the base key "health".
Always set the base key. The suffixed keys are optional - if you skip one, the player sees the default format instead. This means you can support some variants but not all, and it degrades gracefully.
Segments Without Variants
If your segment only has one display format, simply don’t calldefineVariants(). The format button won’t appear on the chain block in the UI, and the segment always displays its base text. You can ignore the variantIndex parameter in your resolver.
Prefix, Suffix, and Bar Customization
When a player selects a format variant, the UI also lets them configure:- Prefix - Text prepended before the value (e.g.
"HP: [") - Suffix - Text appended after the value (e.g.
"]") - Bar empty fill - The character used for unfilled positions in bar variants
Next Steps
- Advanced - Hidden metadata keys, cleanup, and edge cases
- API Reference - Full method tables