Class SocialChatRendererUtil

java.lang.Object
ovh.mythmc.social.api.chat.renderer.SocialChatRendererUtil

public class SocialChatRendererUtil extends Object
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 Details

    • SocialChatRendererUtil

      public SocialChatRendererUtil()
  • Method Details

    • getReplyIcon

      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 TextComponent includes:

      • The configured reply icon
      • Hover text with context
      • Click event suggesting the reply command for this message
      • Optional descriptor text from configuration
      Parameters:
      sender - the SocialUser who will see the icon
      message - the SocialRegisteredMessageContext representing the message
      Returns:
      a TextComponent representing the reply icon, or empty if unavailable
    • trim

      public Component trim(@NotNull @NotNull Component component)
      Trims the leading and trailing whitespace of a Component's textual content.

      If the component is a TextComponent, its content is trimmed; otherwise, the component is returned unchanged.

      Parameters:
      component - the Component to trim
      Returns:
      the trimmed component if textual, or the original component otherwise