Package net.md_5.bungee.api.chat
Class ScoreComponent
- java.lang.Object
-
- net.md_5.bungee.api.chat.BaseComponent
-
- net.md_5.bungee.api.chat.ScoreComponent
-
public final class ScoreComponent extends BaseComponent
This component displays the score based on a player score on the scoreboard.
The name is the name of the player stored on the scoreboard, which may be a "fake" player. It can also be a target selector that must resolve to 1 target, and may target non-player entities.
With a book, /tellraw, or /title, using the wildcard '*' in the place of a name or target selector will cause all players to see their own score in the specified objective.
Signs cannot use the '*' wildcard
These values are filled in by the server-side implementation.
As of 1.12.2, a bug ( MC-56373 ) prevents full usage within hover events.
-
-
Constructor Summary
Constructors Constructor Description ScoreComponent(String name, String objective)Creates a new score component with the specified name and objective.
If not specifically set, value will default to an empty string; signifying that the scoreboard value should take precedence.ScoreComponent(String name, String objective, String value)ScoreComponent(ScoreComponent original)Creates a score component from the original to clone it.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected booleancanEqual(Object other)ScoreComponentduplicate()Clones the BaseComponent and returns the clone.booleanequals(Object o)StringgetName()The name of the entity whose score should be displayed.StringgetObjective()The internal name of the objective the score is attached to.StringgetValue()The optional value to use instead of the one present in the Scoreboard.inthashCode()voidsetName(String name)The name of the entity whose score should be displayed.voidsetObjective(String objective)The internal name of the objective the score is attached to.voidsetValue(String value)The optional value to use instead of the one present in the Scoreboard.protected voidtoLegacyText(StringBuilder builder)protected voidtoPlainText(StringBuilder builder)StringtoString()-
Methods inherited from class net.md_5.bungee.api.chat.BaseComponent
addExtra, addExtra, copyFormatting, copyFormatting, copyFormatting, duplicateWithoutFormatting, getClickEvent, getColor, getColorRaw, getExtra, getFont, getFontRaw, getHoverEvent, getInsertion, hasFormatting, isBold, isBoldRaw, isItalic, isItalicRaw, isObfuscated, isObfuscatedRaw, isStrikethrough, isStrikethroughRaw, isUnderlined, isUnderlinedRaw, retain, setBold, setClickEvent, setColor, setExtra, setFont, setHoverEvent, setInsertion, setItalic, setObfuscated, setStrikethrough, setUnderlined, toLegacyText, toLegacyText, toPlainText, toPlainText
-
-
-
-
Constructor Detail
-
ScoreComponent
public ScoreComponent(String name, String objective)
Creates a new score component with the specified name and objective.
If not specifically set, value will default to an empty string; signifying that the scoreboard value should take precedence. If not null, nor empty,valuewill override any value found in the scoreboard.
The value defaults to an empty string.- Parameters:
name- the name of the entity, or an entity selector, whose score should be displayedobjective- the internal name of the objective the entity's score is attached to
-
ScoreComponent
public ScoreComponent(ScoreComponent original)
Creates a score component from the original to clone it.- Parameters:
original- the original for the new score component
-
-
Method Detail
-
duplicate
public ScoreComponent duplicate()
Description copied from class:BaseComponentClones the BaseComponent and returns the clone.- Specified by:
duplicatein classBaseComponent- Returns:
- The duplicate of this BaseComponent
-
toPlainText
protected void toPlainText(StringBuilder builder)
-
toLegacyText
protected void toLegacyText(StringBuilder builder)
-
getName
public String getName()
The name of the entity whose score should be displayed.
-
getObjective
public String getObjective()
The internal name of the objective the score is attached to.
-
getValue
public String getValue()
The optional value to use instead of the one present in the Scoreboard.
-
setName
public void setName(String name)
The name of the entity whose score should be displayed.
-
setObjective
public void setObjective(String objective)
The internal name of the objective the score is attached to.
-
setValue
public void setValue(String value)
The optional value to use instead of the one present in the Scoreboard.
-
toString
public String toString()
- Overrides:
toStringin classBaseComponent
-
equals
public boolean equals(Object o)
- Overrides:
equalsin classBaseComponent
-
canEqual
protected boolean canEqual(Object other)
- Overrides:
canEqualin classBaseComponent
-
hashCode
public int hashCode()
- Overrides:
hashCodein classBaseComponent
-
-