Package com.nickuc.chat.api.util
Interface Component
public interface Component
This interface is used to encapsulate the components used by nChat.
Creating an instance from a Minecraft component:
Use the from(Object) method to turn it into an nChat component.
Creating a Minecraft component from an instance:
Use the to(Component, Class) method to turn it into a Minecraft component.
-
Method Summary
Modifier and TypeMethodDescriptionclone()Creates a clone of this component's instance.Returns the native component encapsulated by nChat.static ComponentConverts Minecraft components to nChat components.text()Gets the content of this component.static <T> TConverts nChat components to Minecraft components.default <T> TConverts nChat components to Minecraft components.
-
Method Details
-
text
String text()Gets the content of this component.- Returns:
- the content of this component (contain legacy colors)
-
clone
Component clone()Creates a clone of this component's instance.- Returns:
- another instance of this component.
-
component
Object component()Returns the native component encapsulated by nChat.Supported libraries:
- adventure
Component - md_5
TextComponent
- Returns:
- the Minecraft component
- adventure
-
to
Converts nChat components to Minecraft components.Supported libraries:
- adventure
Component - md_5
TextComponent
- Parameters:
minecraftComponentClass- the Minecraft component class- Returns:
- the Minecraft component
- Throws:
IllegalArgumentException- if the supplied component class is not supported
- adventure
-
to
static <T> T to(Component component, Class<T> minecraftComponentClass) throws IllegalArgumentException Converts nChat components to Minecraft components.Supported libraries:
- adventure
Component - md_5
TextComponent
- Parameters:
component- the value of the nChat componentminecraftComponentClass- the Minecraft component class- Returns:
- the Minecraft component
- Throws:
IllegalArgumentException- if the supplied component class is not supported
- adventure
-
from
Converts Minecraft components to nChat components.Supported libraries:
- adventure
Component - md_5
TextComponent
- Parameters:
minecraftComponent- the Minecraft component- Returns:
- the value of the nChat component
- Throws:
IllegalArgumentException- if the supplied component is not supported
- adventure
-