Class SocialChatRendererUtil
java.lang.Object
ovh.mythmc.social.api.chat.renderer.SocialChatRendererUtil
Utility methods for rendering chat components in the chat system.
Provides methods for constructing icons, hover text, and performing lightweight
Component transformations for chat messages.
This class is a utility singleton and should be used statically.
Example usage:
TextComponent replyIcon = SocialChatRendererUtil.getReplyIcon(sender, messageContext);
Component trimmedMessage = SocialChatRendererUtil.trim(originalMessage);
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptiongetReplyIcon(SocialUser sender, SocialRegisteredMessageContext message) Returns a reply icon component for a message, including hover text with thread context and a click event to suggest replying.Trims the leading and trailing whitespace of aComponent's textual content.
-
Constructor Details
-
SocialChatRendererUtil
public SocialChatRendererUtil()
-
-
Method Details
-
getReplyIcon
@NotNull public @NotNull TextComponent getReplyIcon(SocialUser sender, SocialRegisteredMessageContext message) Returns a reply icon component for a message, including hover text with thread context and a click event to suggest replying.The component will be empty if:
- The message is not a reply, or
- The sender does not have permission to send messages in the channel
The hover text will include:
- Messages in the thread (up to 8 recent replies)
- Ellipsis (...) if more than 8 replies exist
- A "click to reply" instruction from the chat configuration
The returned
TextComponentincludes:- The configured reply icon
- Hover text with context
- Click event suggesting the reply command for this message
- Optional descriptor text from configuration
- Parameters:
sender- theSocialUserwho will see the iconmessage- theSocialRegisteredMessageContextrepresenting the message- Returns:
- a
TextComponentrepresenting the reply icon, or empty if unavailable
-
trim
Trims the leading and trailing whitespace of aComponent's textual content.If the component is a
TextComponent, its content is trimmed; otherwise, the component is returned unchanged.- Parameters:
component- theComponentto trim- Returns:
- the trimmed component if textual, or the original component otherwise
-