public abstract class BaseComponent extends Object
| Constructor and Description |
|---|
BaseComponent()
Deprecated.
for use by internal classes only, will be removed.
|
| Modifier and Type | Method and Description |
|---|---|
void |
addExtra(BaseComponent component)
Appends a component to the component.
|
void |
addExtra(String text)
Appends a text element 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
|
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 |
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() |
@Deprecated public BaseComponent()
public void copyFormatting(BaseComponent component)
component - the component to copy frompublic void copyFormatting(BaseComponent component, boolean replace)
component - the component to copy fromreplace - if already set formatting should be replaced by the new
componentpublic void copyFormatting(BaseComponent component, ComponentBuilder.FormatRetention retention, boolean replace)
component - the component to copy fromretention - the formatting to copyreplace - if already set formatting should be replaced by the new
componentpublic void retain(ComponentBuilder.FormatRetention retention)
retention - the formatting to retainpublic abstract BaseComponent duplicate()
@Deprecated public BaseComponent duplicateWithoutFormatting()
public static String toLegacyText(BaseComponent... components)
ChatColor.COLOR_CHARcomponents - the components to convertpublic static String toPlainText(BaseComponent... components)
components - the components to convertpublic void setStyle(ComponentStyle style)
ComponentStyle for this component.
Unlike applyStyle(ComponentStyle), this method will overwrite
all style values on this component.
style - the style to set, or null to set all style values to defaultpublic void setColor(ChatColor color)
color - the component color, or null to use the defaultpublic ChatColor getColor()
ChatColor.WHITE
is returned if no color is found.public ChatColor getColorRaw()
public void setFont(String font)
font - the font to set, or null to use the defaultpublic String getFont()
public String getFontRaw()
public void setBold(Boolean bold)
bold - the new bold state, or null to use the defaultpublic boolean isBold()
public Boolean isBoldRaw()
public void setItalic(Boolean italic)
italic - the new italic state, or null to use the defaultpublic boolean isItalic()
public Boolean isItalicRaw()
public void setUnderlined(Boolean underlined)
underlined - the new underlined state, or null to use the defaultpublic boolean isUnderlined()
public Boolean isUnderlinedRaw()
public void setStrikethrough(Boolean strikethrough)
strikethrough - the new strikethrough state, or null to use the
defaultpublic boolean isStrikethrough()
public Boolean isStrikethroughRaw()
public void setObfuscated(Boolean obfuscated)
obfuscated - the new obfuscated state, or null to use the defaultpublic boolean isObfuscated()
public Boolean isObfuscatedRaw()
public void applyStyle(ComponentStyle style)
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.
style - the style to applypublic void setExtra(List<BaseComponent> components)
public void addExtra(String text)
text - the text to appendpublic void addExtra(BaseComponent component)
component - the component to appendpublic boolean hasStyle()
public boolean hasFormatting()
public String toPlainText()
public String toLegacyText()
ChatColor.COLOR_CHARpublic void setInsertion(String insertion)
public void setClickEvent(ClickEvent clickEvent)
public void setHoverEvent(HoverEvent hoverEvent)
public void setReset(boolean reset)
protected boolean canEqual(Object other)
public ComponentStyle getStyle()
public String getInsertion()
public List<BaseComponent> getExtra()
public ClickEvent getClickEvent()
public HoverEvent getHoverEvent()
public boolean isReset()
Copyright © 2012–2024 SpigotMC. All rights reserved.