Package net.md_5.bungee.api.chat
Class BaseComponent
- java.lang.Object
-
- net.md_5.bungee.api.chat.BaseComponent
-
- Direct Known Subclasses:
KeybindComponent,ScoreComponent,SelectorComponent,TextComponent,TranslatableComponent
public abstract class BaseComponent extends Object
-
-
Constructor Summary
Constructors Constructor Description BaseComponent()Deprecated.for use by internal classes only, will be removed.
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Deprecated Methods Modifier and Type Method Description voidaddExtra(String text)Appends a text element to the component.voidaddExtra(BaseComponent component)Appends a component to the component.protected booleancanEqual(Object other)voidcopyFormatting(BaseComponent component)Copies the events and formatting of a BaseComponent.voidcopyFormatting(BaseComponent component, boolean replace)Copies the events and formatting of a BaseComponent.voidcopyFormatting(BaseComponent component, ComponentBuilder.FormatRetention retention, boolean replace)Copies the specified formatting of a BaseComponent.abstract BaseComponentduplicate()Clones the BaseComponent and returns the clone.BaseComponentduplicateWithoutFormatting()Deprecated.API use discouraged, use traditional duplicatebooleanequals(Object o)ClickEventgetClickEvent()The action to perform when this component (and child components) are clickedChatColorgetColor()Returns the color of this component.ChatColorgetColorRaw()Returns the color of this component without checking the parents color.List<BaseComponent>getExtra()Appended components that inherit this component's formatting and eventsStringgetFont()Returns the font of this component.StringgetFontRaw()Returns the font of this component without checking the parents font.HoverEventgetHoverEvent()The action to perform when this component (and child components) are hovered overStringgetInsertion()The text to insert into the chat when this component (and child components) are clicked while pressing the shift keybooleanhasFormatting()Returns whether the component has any formatting or events applied to itinthashCode()booleanisBold()Returns whether this component is bold.BooleanisBoldRaw()Returns whether this component is bold without checking the parents setting.booleanisItalic()Returns whether this component is italic.BooleanisItalicRaw()Returns whether this component is italic without checking the parents setting.booleanisObfuscated()Returns whether this component is obfuscated.BooleanisObfuscatedRaw()Returns whether this component is obfuscated without checking the parents setting.booleanisReset()Whether this component rejects previous formattingbooleanisStrikethrough()Returns whether this component is strikethrough.BooleanisStrikethroughRaw()Returns whether this component is strikethrough without checking the parents setting.booleanisUnderlined()Returns whether this component is underlined.BooleanisUnderlinedRaw()Returns whether this component is underlined without checking the parents setting.voidretain(ComponentBuilder.FormatRetention retention)Retains only the specified formatting.voidsetBold(Boolean bold)Whether this component and any child components (unless overridden) is boldvoidsetClickEvent(ClickEvent clickEvent)The action to perform when this component (and child components) are clickedvoidsetColor(ChatColor color)The color of this component and any child components (unless overridden)voidsetExtra(List<BaseComponent> components)voidsetFont(String font)The font of this component and any child components (unless overridden)voidsetHoverEvent(HoverEvent hoverEvent)The action to perform when this component (and child components) are hovered overvoidsetInsertion(String insertion)The text to insert into the chat when this component (and child components) are clicked while pressing the shift keyvoidsetItalic(Boolean italic)Whether this component and any child components (unless overridden) is italicvoidsetObfuscated(Boolean obfuscated)Whether this component and any child components (unless overridden) is obfuscatedvoidsetReset(boolean reset)Whether this component rejects previous formattingvoidsetStrikethrough(Boolean strikethrough)Whether this component and any child components (unless overridden) is strikethroughvoidsetUnderlined(Boolean underlined)Whether this component and any child components (unless overridden) is underlinedStringtoLegacyText()Converts the component to a string that uses the old formatting codes (ChatColor.COLOR_CHARstatic StringtoLegacyText(BaseComponent... components)Converts the components to a string that uses the old formatting codes (ChatColor.COLOR_CHARStringtoPlainText()Converts the component into a string without any formattingstatic StringtoPlainText(BaseComponent... components)Converts the components into a string without any formattingStringtoString()
-
-
-
Constructor Detail
-
BaseComponent
@Deprecated public BaseComponent()
Deprecated.for use by internal classes only, will be removed.Default constructor.
-
-
Method Detail
-
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 fromreplace- 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 fromretention- the formatting to copyreplace- 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 duplicateClones 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
-
getColor
public ChatColor getColor()
Returns the color of this component. This uses the parent's color if this component doesn't have one.ChatColor.WHITEis 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
-
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
-
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
-
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
-
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
-
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
-
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
-
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
-
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
-
setColor
public void setColor(ChatColor color)
The color of this component and any child components (unless overridden)
-
setFont
public void setFont(String font)
The font of this component and any child components (unless overridden)
-
setBold
public void setBold(Boolean bold)
Whether this component and any child components (unless overridden) is bold
-
setItalic
public void setItalic(Boolean italic)
Whether this component and any child components (unless overridden) is italic
-
setUnderlined
public void setUnderlined(Boolean underlined)
Whether this component and any child components (unless overridden) is underlined
-
setStrikethrough
public void setStrikethrough(Boolean strikethrough)
Whether this component and any child components (unless overridden) is strikethrough
-
setObfuscated
public void setObfuscated(Boolean obfuscated)
Whether this component and any child components (unless overridden) is obfuscated
-
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
-
canEqual
protected boolean canEqual(Object other)
-
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
-
-