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
-
Constructor Summary
ConstructorsConstructorDescriptionDeprecated.for use by internal classes only, will be removed. -
Method Summary
Modifier and TypeMethodDescriptionvoid
Appends a text element to the component.void
addExtra
(BaseComponent component) Appends a component to the component.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
Clones the BaseComponent and returns the clone.Deprecated.API use discouraged, use traditional duplicategetColor()
Returns the color of this component.Returns the color of this component without checking the parents color.getFont()
Returns the font of this component.Returns the font of this component without checking the parents font.boolean
Returns whether the component has any formatting or events applied to itboolean
isBold()
Returns whether this component is bold.Returns whether this component is bold without checking the parents setting.boolean
isItalic()
Returns whether this component is italic.Returns whether this component is italic without checking the parents setting.boolean
Returns whether this component is obfuscated.Returns whether this component is obfuscated without checking the parents setting.boolean
Returns whether this component is strikethrough.Returns whether this component is strikethrough without checking the parents setting.boolean
Returns whether this component is underlined.Returns whether this component is underlined without checking the parents setting.void
retain
(ComponentBuilder.FormatRetention retention) Retains only the specified formatting.void
setExtra
(List<BaseComponent> components) 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
Converts the component into a string without any formattingstatic String
toPlainText
(BaseComponent... components) Converts the components into a string without any formatting
-
Constructor Details
-
BaseComponent
Deprecated.for use by internal classes only, will be removed.Default constructor.
-
-
Method Details
-
copyFormatting
Copies the events and formatting of a BaseComponent. Already set formatting will be replaced.- Parameters:
component
- the component to copy from
-
copyFormatting
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
Retains only the specified formatting.- Parameters:
retention
- the formatting to retain
-
duplicate
Clones the BaseComponent and returns the clone.- Returns:
- The duplicate of this BaseComponent
-
duplicateWithoutFormatting
Deprecated.API use discouraged, use traditional duplicateClones the BaseComponent without formatting and returns the clone.- Returns:
- The duplicate of this BaseComponent
-
toLegacyText
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
Converts the components into a string without any formatting- Parameters:
components
- the components to convert- Returns:
- the string as plain text
-
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
Returns the color of this component without checking the parents color. May return null- Returns:
- the color of this component
-
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
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
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
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
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
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
Returns whether this component is obfuscated without checking the parents setting. May return null- Returns:
- whether the component is obfuscated
-
setExtra
-
addExtra
Appends a text element to the component. The text will inherit this component's formatting- Parameters:
text
- the text to append
-
addExtra
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
Converts the component into a string without any formatting- Returns:
- the string as plain text
-
toLegacyText
Converts the component to a string that uses the old formatting codes (ChatColor.COLOR_CHAR
- Returns:
- the string in the old format
-