Class ItemTooltip
java.lang.Object
net.risingworld.api.ui.ItemTooltip
Represents a custom tooltip for a particular item. An item tooltip consists of four sections, and every section
can be modified individually: the name (header of the tooltip), the modifier (shown next to the header), the info
text (shown below the header) and the condition (the colored indicator at the bottom). Sections which are not set
remain unchanged, so it's possible to only add an additional info line, for example.
Texts may contain formatting tags (like
Please note that item tooltips are not persistent: they are lost when the server restarts or when the player reconnects, so a plugin has to set them again (e.g. when a player spawns).
Texts may contain formatting tags (like
<color=#FF0000>, <b> or
<i>) as well as line breaks.Please note that item tooltips are not persistent: they are lost when the server restarts or when the player reconnects, so a plugin has to set them again (e.g. when a player spawns).
- See Also:
- Example: Set a custom name and add an info line
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enumDetermines how the text of a section is combined with the original (vanilla) text -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intCondition color which the game uses for badly damaged items (rgba)static final intCondition color which the game uses for damaged items (rgba)static final intCondition color which the game uses for pristine items (rgba)static final intCondition color which the game uses for broken or spoiled items (rgba)static final intCondition color which the game uses for worn items (rgba)static final intMaximum amount of bytes a single tooltip may have -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic ItemTooltipfromBytes(byte[] data) Creates a tooltip out of the serialized format which the game uses internally.intGets the color of the condition indicator.Gets the mode of the condition section.String[]Gets the localized texts of the condition section.Gets the mode of the info section.String[]Gets the localized texts of the info section.Gets the mode of the modifier section.String[]Gets the localized texts of the modifier section.Gets the mode of the name section.String[]Gets the localized texts of the name section.Hides the condition of the item.booleanisEmpty()Checks whether or not this tooltip is empty, i.e no section was set.Resets the condition, i.e the game shows the regular condition of the item again.setCondition(String[] localizedTexts, int rgba) Replaces the condition of the item, with a separate text per language.setCondition(String text, int rgba) Replaces the condition of the item, i.e the text and the color of the indicator at the bottom of the tooltip.setInfo(ItemTooltip.Mode mode, String text) Sets the info section of the tooltip (shown below the header).setInfo(ItemTooltip.Mode mode, String[] localizedTexts) Sets the info section of the tooltip, with a separate text per language.setModifier(ItemTooltip.Mode mode, String text) Sets the modifier section of the tooltip (shown next to the header).setModifier(ItemTooltip.Mode mode, String[] localizedTexts) Sets the modifier section of the tooltip, with a separate text per language.setName(ItemTooltip.Mode mode, String text) Sets the name section (header) of the tooltip.setName(ItemTooltip.Mode mode, String[] localizedTexts) Sets the name section (header) of the tooltip, with a separate text per language.byte[]toBytes()Converts this tooltip into the serialized format which the game uses internally.
-
Field Details
-
COLOR_PRISTINE
public static final int COLOR_PRISTINECondition color which the game uses for pristine items (rgba)- See Also:
-
COLOR_WORN
public static final int COLOR_WORNCondition color which the game uses for worn items (rgba)- See Also:
-
COLOR_DAMAGED
public static final int COLOR_DAMAGEDCondition color which the game uses for damaged items (rgba)- See Also:
-
COLOR_BADLY_DAMAGED
public static final int COLOR_BADLY_DAMAGEDCondition color which the game uses for badly damaged items (rgba)- See Also:
-
COLOR_RUINED
public static final int COLOR_RUINEDCondition color which the game uses for broken or spoiled items (rgba)- See Also:
-
MAX_BYTES
public static final int MAX_BYTESMaximum amount of bytes a single tooltip may have- See Also:
-
-
Constructor Details
-
ItemTooltip
public ItemTooltip()
-
-
Method Details
-
setName
Sets the name section (header) of the tooltip.- Parameters:
mode- determines how the text is combined with the original name.text- the text. May be null if the mode does not need a text (e.g.ItemTooltip.Mode.Hide).- Returns:
- this tooltip instance.
-
setName
Sets the name section (header) of the tooltip, with a separate text per language.- Parameters:
mode- determines how the text is combined with the original name.localizedTexts- the localized texts, e.g{"en=Pickaxe", "de=Spitzhacke"}. An entry without a language prefix is used for all languages.- Returns:
- this tooltip instance.
-
setModifier
Sets the modifier section of the tooltip (shown next to the header).- Parameters:
mode- determines how the text is combined with the original modifier.text- the text. May be null if the mode does not need a text.- Returns:
- this tooltip instance.
-
setModifier
Sets the modifier section of the tooltip, with a separate text per language.- Parameters:
mode- determines how the text is combined with the original modifier.localizedTexts- the localized texts, e.g{"en=Rusty", "de=Rostig"}.- Returns:
- this tooltip instance.
-
setInfo
Sets the info section of the tooltip (shown below the header). Appended or prepended texts are separated by a line break.- Parameters:
mode- determines how the text is combined with the original info text.text- the text. May be null if the mode does not need a text.- Returns:
- this tooltip instance.
-
setInfo
Sets the info section of the tooltip, with a separate text per language.- Parameters:
mode- determines how the text is combined with the original info text.localizedTexts- the localized texts, e.g{"en=Heavy", "de=Schwer"}.- Returns:
- this tooltip instance.
-
setCondition
Replaces the condition of the item, i.e the text and the color of the indicator at the bottom of the tooltip.- Parameters:
text- the condition text.rgba- color of the condition indicator (e.gCOLOR_PRISTINE).- Returns:
- this tooltip instance.
-
setCondition
Replaces the condition of the item, with a separate text per language.- Parameters:
localizedTexts- the localized texts, e.g{"en=Soulbound", "de=Seelengebunden"}.rgba- color of the condition indicator (e.gCOLOR_PRISTINE).- Returns:
- this tooltip instance.
-
hideCondition
-
resetCondition
Resets the condition, i.e the game shows the regular condition of the item again.- Returns:
- this tooltip instance.
-
isEmpty
public boolean isEmpty()Checks whether or not this tooltip is empty, i.e no section was set.- Returns:
- true if no section was set, false if at least one section was set.
-
getNameMode
Gets the mode of the name section.- Returns:
- the mode of the name section, or
ItemTooltip.Mode.Keepif the section was not set.
-
getModifierMode
Gets the mode of the modifier section.- Returns:
- the mode of the modifier section, or
ItemTooltip.Mode.Keepif the section was not set.
-
getInfoMode
Gets the mode of the info section.- Returns:
- the mode of the info section, or
ItemTooltip.Mode.Keepif the section was not set.
-
getConditionMode
Gets the mode of the condition section.- Returns:
- the mode of the condition section, or
ItemTooltip.Mode.Keepif the section was not set.
-
getNameTexts
Gets the localized texts of the name section.- Returns:
- the texts (in the format
"en=Text"), or null if the section was not set.
-
getModifierTexts
Gets the localized texts of the modifier section.- Returns:
- the texts (in the format
"en=Text"), or null if the section was not set.
-
getInfoTexts
Gets the localized texts of the info section.- Returns:
- the texts (in the format
"en=Text"), or null if the section was not set.
-
getConditionTexts
Gets the localized texts of the condition section.- Returns:
- the texts (in the format
"en=Text"), or null if the section was not set.
-
getConditionColor
public int getConditionColor()Gets the color of the condition indicator.- Returns:
- the rgba color of the condition indicator.
-
toBytes
public byte[] toBytes()Converts this tooltip into the serialized format which the game uses internally.- Returns:
- the serialized tooltip, or null if this tooltip is empty.
-
fromBytes
Creates a tooltip out of the serialized format which the game uses internally.- Parameters:
data- the serialized tooltip.- Returns:
- the tooltip, or null if the data was null or invalid.
-