Interface ComponentDecorator
public interface ComponentDecorator
A utility class for decorating Adventure
Component objects with hover events and text decorations.
This decorator recursively applies decorations to components, including their children and translation arguments.- Since:
- 1.10.0
-
Method Summary
Modifier and TypeMethodDescriptionnet.kyori.adventure.text.Componentdecorate(net.kyori.adventure.text.Component component, net.kyori.adventure.text.format.TextDecoration decoration, net.kyori.adventure.text.format.TextDecoration.State state) Applies a text decoration to the given component.net.kyori.adventure.text.Componentdecorate(net.kyori.adventure.text.Component component, net.kyori.adventure.text.format.TextDecoration decoration, net.kyori.adventure.text.format.TextDecoration.State state, boolean ifAbsent) Applies a text decoration to the given component with control over whether to overwrite existing decorations.net.kyori.adventure.text.ComponentdecorateIfAbsent(net.kyori.adventure.text.Component component, net.kyori.adventure.text.format.TextDecoration decoration, net.kyori.adventure.text.format.TextDecoration.State state) Applies a text decoration to the given component only if that decoration is not already set.net.kyori.adventure.text.Componenthover(net.kyori.adventure.text.Component component, net.kyori.adventure.text.event.HoverEvent<?> hoverEvent) Adds a hover event to the given component.net.kyori.adventure.text.Componenthover(net.kyori.adventure.text.Component component, net.kyori.adventure.text.event.HoverEvent<?> hoverEvent, boolean ifAbsent) Adds a hover event to the given component with control over whether to overwrite existing hover events.net.kyori.adventure.text.ComponenthoverIfAbsent(net.kyori.adventure.text.Component component, net.kyori.adventure.text.event.HoverEvent<?> hoverEvent) Adds a hover event to the given component only if no hover event is already present.
-
Method Details
-
hover
net.kyori.adventure.text.Component hover(net.kyori.adventure.text.Component component, net.kyori.adventure.text.event.HoverEvent<?> hoverEvent) Adds a hover event to the given component. This method will overwrite any existing hover event on the component.- Parameters:
component- the component to add the hover event tohoverEvent- the hover event to apply- Returns:
- a new component with the hover event applied
-
hoverIfAbsent
net.kyori.adventure.text.Component hoverIfAbsent(net.kyori.adventure.text.Component component, net.kyori.adventure.text.event.HoverEvent<?> hoverEvent) Adds a hover event to the given component only if no hover event is already present.- Parameters:
component- the component to add the hover event tohoverEvent- the hover event to apply- Returns:
- a new component with the hover event applied if it was absent
-
hover
net.kyori.adventure.text.Component hover(net.kyori.adventure.text.Component component, net.kyori.adventure.text.event.HoverEvent<?> hoverEvent, boolean ifAbsent) Adds a hover event to the given component with control over whether to overwrite existing hover events. This method recursively processes the component's children and translation arguments to ensure consistent hover behavior throughout the component tree.- Parameters:
component- the component to add the hover event tohoverEvent- the hover event to applyifAbsent- if true, only adds the hover event if one is not already present; if false, overwrites any existing hover event- Returns:
- a new component with the hover event applied to it, its children, and translation arguments
-
decorate
net.kyori.adventure.text.Component decorate(net.kyori.adventure.text.Component component, net.kyori.adventure.text.format.TextDecoration decoration, net.kyori.adventure.text.format.TextDecoration.State state) Applies a text decoration to the given component. This method will overwrite any existing state of the specified decoration.- Parameters:
component- the component to decoratedecoration- the text decoration to apply (e.g., BOLD, ITALIC, UNDERLINED)state- the state of the decoration (TRUE, FALSE, or NOT_SET)- Returns:
- a new component with the text decoration applied
-
decorateIfAbsent
net.kyori.adventure.text.Component decorateIfAbsent(net.kyori.adventure.text.Component component, net.kyori.adventure.text.format.TextDecoration decoration, net.kyori.adventure.text.format.TextDecoration.State state) Applies a text decoration to the given component only if that decoration is not already set.- Parameters:
component- the component to decoratedecoration- the text decoration to apply (e.g., BOLD, ITALIC, UNDERLINED)state- the state of the decoration (TRUE, FALSE, or NOT_SET)- Returns:
- a new component with the text decoration applied if it was absent
-
decorate
net.kyori.adventure.text.Component decorate(net.kyori.adventure.text.Component component, net.kyori.adventure.text.format.TextDecoration decoration, net.kyori.adventure.text.format.TextDecoration.State state, boolean ifAbsent) Applies a text decoration to the given component with control over whether to overwrite existing decorations. This method recursively processes the component's children and translation arguments to ensure consistent decoration throughout the component tree.- Parameters:
component- the component to decoratedecoration- the text decoration to apply (e.g., BOLD, ITALIC, UNDERLINED)state- the state of the decoration (TRUE, FALSE, or NOT_SET)ifAbsent- if true, only applies the decoration if it is not already set; if false, overwrites any existing decoration state- Returns:
- a new component with the text decoration applied to it, its children, and translation arguments
-