Package net.md_5.bungee.api.chat

# Class BaseComponent

java.lang.Object
net.md_5.bungee.api.chat.BaseComponent

Direct Known Subclasses:
  `KeybindComponent`, `ObjectComponent`, `ScoreComponent`, `SelectorComponent`, `TextComponent`, `TranslatableComponent`

public abstract class BaseComponent extends Object

- ## Nested Class Summary

  Nested Classes
  Modifier and Type
  Class
  Description
  `protected static class`
  `BaseComponent.LimitedStringVisitor`
  `protected static interface`
  `BaseComponent.StringVisitor`

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `BaseComponent()`
  Deprecated.
  for use by internal classes only, will be removed.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `void`
  `addExtra(String text)`
  Appends a text element to the component.
  `void`
  `addExtra(BaseComponent component)`
  Appends a component to the component.
  `void`
  `applyStyle(ComponentStyle style)`
  Apply the style from the given `ComponentStyle` to this component.
  `protected boolean`
  `canEqual(Object other)`
  `void`
  `copyFormatting(BaseComponent component)`
  Copies the events and formatting of a BaseComponent.
  `void`
  `copyFormatting(BaseComponent component, boolean replace)`
  Copies the events and formatting of a BaseComponent.
  `void`
  `copyFormatting(BaseComponent component, ComponentBuilder.FormatRetention retention, boolean replace)`
  Copies the specified formatting of a BaseComponent.
  `abstract BaseComponent`
  `duplicate()`
  Clones the BaseComponent and returns the clone.
  `BaseComponent`
  `duplicateWithoutFormatting()`
  Deprecated.
  API use discouraged, use traditional duplicate
  `boolean`
  `equals(Object o)`
  `ClickEvent`
  `getClickEvent()`
  The action to perform when this component (and child components) are clicked
  `ChatColor`
  `getColor()`
  Returns the color of this component.
  `ChatColor`
  `getColorRaw()`
  Returns the color of this component without checking the parents color.
  `List<BaseComponent>`
  `getExtra()`
  Appended components that inherit this component's formatting and events
  `String`
  `getFont()`
  Returns the font of this component.
  `String`
  `getFontRaw()`
  Returns the font of this component without checking the parents font.
  `HoverEvent`
  `getHoverEvent()`
  The action to perform when this component (and child components) are hovered over
  `String`
  `getInsertion()`
  The text to insert into the chat when this component (and child components) are clicked while pressing the shift key
  `Color`
  `getShadowColor()`
  Returns the shadow color of this component.
  `Color`
  `getShadowColorRaw()`
  Returns the shadow color of this component without checking the parents shadow color.
  `ComponentStyle`
  `getStyle()`
  The component's style.
  `boolean`
  `hasFormatting()`
  Returns whether the component has any formatting or events applied to it
  `int`
  `hashCode()`
  `boolean`
  `hasStyle()`
  Returns whether the component has any styling applied to it.
  `boolean`
  `isBold()`
  Returns whether this component is bold.
  `Boolean`
  `isBoldRaw()`
  Returns whether this component is bold without checking the parents setting.
  `boolean`
  `isItalic()`
  Returns whether this component is italic.
  `Boolean`
  `isItalicRaw()`
  Returns whether this component is italic without checking the parents setting.
  `boolean`
  `isObfuscated()`
  Returns whether this component is obfuscated.
  `Boolean`
  `isObfuscatedRaw()`
  Returns whether this component is obfuscated without checking the parents setting.
  `boolean`
  `isReset()`
  Whether this component rejects previous formatting
  `boolean`
  `isStrikethrough()`
  Returns whether this component is strikethrough.
  `Boolean`
  `isStrikethroughRaw()`
  Returns whether this component is strikethrough without checking the parents setting.
  `boolean`
  `isUnderlined()`
  Returns whether this component is underlined.
  `Boolean`
  `isUnderlinedRaw()`
  Returns whether this component is underlined without checking the parents setting.
  `void`
  `retain(ComponentBuilder.FormatRetention retention)`
  Retains only the specified formatting.
  `void`
  `setBold(Boolean bold)`
  Set whether or not this component is bold.
  `void`
  `setClickEvent(ClickEvent clickEvent)`
  The action to perform when this component (and child components) are clicked
  `void`
  `setColor(ChatColor color)`
  Set this component's color.
  `void`
  `setExtra(List<BaseComponent> components)`
  `void`
  `setFont(String font)`
  Set this component's font.
  `void`
  `setHoverEvent(HoverEvent hoverEvent)`
  The action to perform when this component (and child components) are hovered over
  `void`
  `setInsertion(String insertion)`
  The text to insert into the chat when this component (and child components) are clicked while pressing the shift key
  `void`
  `setItalic(Boolean italic)`
  Set whether or not this component is italic.
  `void`
  `setObfuscated(Boolean obfuscated)`
  Set whether or not this component is obfuscated.
  `void`
  `setReset(boolean reset)`
  Whether this component rejects previous formatting
  `void`
  `setShadowColor(Color color)`
  Set this component's shadow color.
  `void`
  `setStrikethrough(Boolean strikethrough)`
  Set whether or not this component is strikethrough.
  `void`
  `setStyle(ComponentStyle style)`
  Set the `ComponentStyle` for this component.
  `void`
  `setUnderlined(Boolean underlined)`
  Set whether or not this component is underlined.
  `String`
  `toLegacyText()`
  Converts the component to a string that uses the old formatting codes (`ChatColor.COLOR_CHAR`
  `static String`
  `toLegacyText(BaseComponent... components)`
  Converts the components to a string that uses the old formatting codes (`ChatColor.COLOR_CHAR`
  `String`
  `toPlainText()`
  Converts the component into a string without any formatting
  `static String`
  `toPlainText(BaseComponent... components)`
  Converts the components into a string without any formatting
  `String`
  `toString()`

  ### Methods inherited from class java.lang.Object

  `clone, finalize, getClass, notify, notifyAll, wait, wait, wait`

- ## Constructor Details

  - ### BaseComponent

    @Deprecated public BaseComponent()
    Deprecated.
    for use by internal classes only, will be removed.
    Default constructor.

- ## Method Details

  - ### copyFormatting

    public void copyFormatting(BaseComponent component)
    Copies the events and formatting of a BaseComponent. Already set formatting will be replaced.
    Parameters:
      `component` - the component to copy from

  - ### copyFormatting

    public void copyFormatting(BaseComponent component, boolean replace)
    Copies the events and formatting of a BaseComponent.
    Parameters:
      `component` - the component to copy from
      `replace` - if already set formatting should be replaced by the new component

  - ### copyFormatting

    public void copyFormatting(BaseComponent component, ComponentBuilder.FormatRetention retention, boolean replace)
    Copies the specified formatting of a BaseComponent.
    Parameters:
      `component` - the component to copy from
      `retention` - the formatting to copy
      `replace` - if already set formatting should be replaced by the new component

  - ### retain

    public void retain(ComponentBuilder.FormatRetention retention)
    Retains only the specified formatting.
    Parameters:
      `retention` - the formatting to retain

  - ### duplicate

    public abstract BaseComponent duplicate()
    Clones the BaseComponent and returns the clone.
    Returns:
      The duplicate of this BaseComponent

  - ### duplicateWithoutFormatting

    @Deprecated public BaseComponent duplicateWithoutFormatting()
    Deprecated.
    API use discouraged, use traditional duplicate
    Clones the BaseComponent without formatting and returns the clone.
    Returns:
      The duplicate of this BaseComponent

  - ### toLegacyText

    public static String toLegacyText(BaseComponent... components)
    Converts the components to a string that uses the old formatting codes (`ChatColor.COLOR_CHAR`
    Parameters:
      `components` - the components to convert
    Returns:
      the string in the old format

  - ### toPlainText

    public static String toPlainText(BaseComponent... components)
    Converts the components into a string without any formatting
    Parameters:
      `components` - the components to convert
    Returns:
      the string as plain text

  - ### setStyle

    public void setStyle(ComponentStyle style)
    Set the `ComponentStyle` for this component.

    Unlike `applyStyle(ComponentStyle)`, this method will overwrite all style values on this component.

    Parameters:
      `style` - the style to set, or null to set all style values to default

  - ### setColor

    public void setColor(ChatColor color)
    Set this component's color.

    Warning: This should be a color, not formatting code (ie, `ChatColor.color` should not be null).

    Parameters:
      `color` - the component color, or null to use the default

  - ### getColor

    public ChatColor getColor()
    Returns the color of this component. This uses the parent's color if this component doesn't have one. `ChatColor.WHITE` is returned if no color is found.
    Returns:
      the color of this component

  - ### getColorRaw

    public ChatColor getColorRaw()
    Returns the color of this component without checking the parents color. May return null
    Returns:
      the color of this component

  - ### setShadowColor

    public void setShadowColor(Color color)
    Set this component's shadow color.
    Parameters:
      `color` - the component shadow color, or null to use the default

  - ### getShadowColor

    public Color getShadowColor()
    Returns the shadow color of this component. This uses the parent's shadow color if this component doesn't have one. null is returned if no shadow color is found.
    Returns:
      the shadow color of this component

  - ### getShadowColorRaw

    public Color getShadowColorRaw()
    Returns the shadow color of this component without checking the parents shadow color. May return null
    Returns:
      the shadow color of this component

  - ### setFont

    public void setFont(String font)
    Set this component's font.
    Parameters:
      `font` - the font to set, or null to use the default

  - ### getFont

    public String getFont()
    Returns the font of this component. This uses the parent's font if this component doesn't have one.
    Returns:
      the font of this component, or null if default font

  - ### getFontRaw

    public String getFontRaw()
    Returns the font of this component without checking the parents font. May return null
    Returns:
      the font of this component

  - ### setBold

    public void setBold(Boolean bold)
    Set whether or not this component is bold.
    Parameters:
      `bold` - the new bold state, or null to use the default

  - ### isBold

    public boolean isBold()
    Returns whether this component is bold. This uses the parent's setting if this component hasn't been set. false is returned if none of the parent chain has been set.
    Returns:
      whether the component is bold

  - ### isBoldRaw

    public Boolean isBoldRaw()
    Returns whether this component is bold without checking the parents setting. May return null
    Returns:
      whether the component is bold

  - ### setItalic

    public void setItalic(Boolean italic)
    Set whether or not this component is italic.
    Parameters:
      `italic` - the new italic state, or null to use the default

  - ### isItalic

    public boolean isItalic()
    Returns whether this component is italic. This uses the parent's setting if this component hasn't been set. false is returned if none of the parent chain has been set.
    Returns:
      whether the component is italic

  - ### isItalicRaw

    public Boolean isItalicRaw()
    Returns whether this component is italic without checking the parents setting. May return null
    Returns:
      whether the component is italic

  - ### setUnderlined

    public void setUnderlined(Boolean underlined)
    Set whether or not this component is underlined.
    Parameters:
      `underlined` - the new underlined state, or null to use the default

  - ### isUnderlined

    public boolean isUnderlined()
    Returns whether this component is underlined. This uses the parent's setting if this component hasn't been set. false is returned if none of the parent chain has been set.
    Returns:
      whether the component is underlined

  - ### isUnderlinedRaw

    public Boolean isUnderlinedRaw()
    Returns whether this component is underlined without checking the parents setting. May return null
    Returns:
      whether the component is underlined

  - ### setStrikethrough

    public void setStrikethrough(Boolean strikethrough)
    Set whether or not this component is strikethrough.
    Parameters:
      `strikethrough` - the new strikethrough state, or null to use the default

  - ### isStrikethrough

    public boolean isStrikethrough()
    Returns whether this component is strikethrough. This uses the parent's setting if this component hasn't been set. false is returned if none of the parent chain has been set.
    Returns:
      whether the component is strikethrough

  - ### isStrikethroughRaw

    public Boolean isStrikethroughRaw()
    Returns whether this component is strikethrough without checking the parents setting. May return null
    Returns:
      whether the component is strikethrough

  - ### setObfuscated

    public void setObfuscated(Boolean obfuscated)
    Set whether or not this component is obfuscated.
    Parameters:
      `obfuscated` - the new obfuscated state, or null to use the default

  - ### isObfuscated

    public boolean isObfuscated()
    Returns whether this component is obfuscated. This uses the parent's setting if this component hasn't been set. false is returned if none of the parent chain has been set.
    Returns:
      whether the component is obfuscated

  - ### isObfuscatedRaw

    public Boolean isObfuscatedRaw()
    Returns whether this component is obfuscated without checking the parents setting. May return null
    Returns:
      whether the component is obfuscated

  - ### applyStyle

    public void applyStyle(ComponentStyle style)
    Apply the style from the given `ComponentStyle` to this component.

    Any style values that have been explicitly set in the style will be applied to this component. If a value is not set in the style, it will not override the style set in this component.

    Parameters:
      `style` - the style to apply

  - ### setExtra

    public void setExtra(List<BaseComponent> components)

  - ### addExtra

    public void addExtra(String text)
    Appends a text element to the component. The text will inherit this component's formatting
    Parameters:
      `text` - the text to append

  - ### addExtra

    public void addExtra(BaseComponent component)
    Appends a component to the component. The text will inherit this component's formatting
    Parameters:
      `component` - the component to append

  - ### hasStyle

    public boolean hasStyle()
    Returns whether the component has any styling applied to it.
    Returns:
      Whether any styling is applied

  - ### hasFormatting

    public boolean hasFormatting()
    Returns whether the component has any formatting or events applied to it
    Returns:
      Whether any formatting or events are applied

  - ### toPlainText

    public String toPlainText()
    Converts the component into a string without any formatting
    Returns:
      the string as plain text

  - ### toLegacyText

    public String toLegacyText()
    Converts the component to a string that uses the old formatting codes (`ChatColor.COLOR_CHAR`
    Returns:
      the string in the old format

  - ### setInsertion

    public void setInsertion(String insertion)
    The text to insert into the chat when this component (and child components) are clicked while pressing the shift key

  - ### setClickEvent

    public void setClickEvent(ClickEvent clickEvent)
    The action to perform when this component (and child components) are clicked

  - ### setHoverEvent

    public void setHoverEvent(HoverEvent hoverEvent)
    The action to perform when this component (and child components) are hovered over

  - ### setReset

    public void setReset(boolean reset)
    Whether this component rejects previous formatting

  - ### toString

    public String toString()
    Overrides:
      `toString` in class `Object`

  - ### equals

    public boolean equals(Object o)
    Overrides:
      `equals` in class `Object`

  - ### canEqual

    protected boolean canEqual(Object other)

  - ### hashCode

    public int hashCode()
    Overrides:
      `hashCode` in class `Object`

  - ### getStyle

    public ComponentStyle getStyle()
    The component's style.

  - ### getInsertion

    public String getInsertion()
    The text to insert into the chat when this component (and child components) are clicked while pressing the shift key

  - ### getExtra

    public List<BaseComponent> getExtra()
    Appended components that inherit this component's formatting and events

  - ### getClickEvent

    public ClickEvent getClickEvent()
    The action to perform when this component (and child components) are clicked

  - ### getHoverEvent

    public HoverEvent getHoverEvent()
    The action to perform when this component (and child components) are hovered over

  - ### isReset

    public boolean isReset()
    Whether this component rejects previous formatting