Class ComponentStyleBuilder


  • 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);
     
    See Also:
    ComponentStyle.builder(), ComponentStyle.builder(ComponentStyle)
    • Constructor Detail

      • ComponentStyleBuilder

        public ComponentStyleBuilder()
    • Method Detail

      • color

        public ComponentStyleBuilder color​(ChatColor color)
        Set the style color.
        Parameters:
        color - the color to set, or null to use the default
        Returns:
        this ComponentStyleBuilder for chaining
      • font

        public ComponentStyleBuilder font​(String font)
        Set the style font.
        Parameters:
        font - the font key to set, or null to use the default
        Returns:
        this ComponentStyleBuilder for chaining
      • bold

        public ComponentStyleBuilder bold​(Boolean bold)
        Set the style's bold property.
        Parameters:
        bold - the bold value to set, or null to use the default
        Returns:
        this ComponentStyleBuilder for chaining
      • italic

        public ComponentStyleBuilder italic​(Boolean italic)
        Set the style's italic property.
        Parameters:
        italic - the italic value to set, or null to use the default
        Returns:
        this ComponentStyleBuilder for chaining
      • underlined

        public ComponentStyleBuilder underlined​(Boolean underlined)
        Set the style's underlined property.
        Parameters:
        underlined - the underlined value to set, or null to use the default
        Returns:
        this ComponentStyleBuilder for chaining
      • strikethrough

        public ComponentStyleBuilder strikethrough​(Boolean strikethrough)
        Set the style's strikethrough property.
        Parameters:
        strikethrough - the strikethrough value to set, or null to use the default
        Returns:
        this ComponentStyleBuilder for chaining
      • obfuscated

        public ComponentStyleBuilder obfuscated​(Boolean obfuscated)
        Set the style's obfuscated property.
        Parameters:
        obfuscated - the obfuscated value to set, or null to use the default
        Returns:
        this ComponentStyleBuilder for chaining