public final class ComponentStyleBuilder extends Object
ComponentStyleBuilder simplifies creating component styles by allowing the use of a chainable builder.
ComponentStyle style = ComponentStyle.builder()
.color(ChatColor.RED)
.font("custom:font")
.bold(true).italic(true).create();
BaseComponent component = new ComponentBuilder("Hello world").style(style).create();
// Or it can be used directly on a component
TextComponent text = new TextComponent("Hello world");
text.applyStyle(style);
| Constructor and Description |
|---|
ComponentStyleBuilder() |
| Modifier and Type | Method and Description |
|---|---|
ComponentStyleBuilder |
bold(Boolean bold)
Set the style's bold property.
|
ComponentStyle |
build()
Build the
ComponentStyle using the values set in this builder. |
ComponentStyleBuilder |
color(ChatColor color)
Set the style color.
|
ComponentStyleBuilder |
font(String font)
Set the style font.
|
ComponentStyleBuilder |
italic(Boolean italic)
Set the style's italic property.
|
ComponentStyleBuilder |
obfuscated(Boolean obfuscated)
Set the style's obfuscated property.
|
ComponentStyleBuilder |
strikethrough(Boolean strikethrough)
Set the style's strikethrough property.
|
ComponentStyleBuilder |
underlined(Boolean underlined)
Set the style's underlined property.
|
public ComponentStyleBuilder color(ChatColor color)
color - the color to set, or null to use the defaultpublic ComponentStyleBuilder font(String font)
font - the font key to set, or null to use the defaultpublic ComponentStyleBuilder bold(Boolean bold)
bold - the bold value to set, or null to use the defaultpublic ComponentStyleBuilder italic(Boolean italic)
italic - the italic value to set, or null to use the defaultpublic ComponentStyleBuilder underlined(Boolean underlined)
underlined - the underlined value to set, or null to use the defaultpublic ComponentStyleBuilder strikethrough(Boolean strikethrough)
strikethrough - the strikethrough value to set, or null to use the
defaultpublic ComponentStyleBuilder obfuscated(Boolean obfuscated)
obfuscated - the obfuscated value to set, or null to use the defaultpublic ComponentStyle build()
ComponentStyle using the values set in this builder.Copyright © 2012–2024 SpigotMC. All rights reserved.