Class ChatHistory

java.lang.Object
ovh.mythmc.social.api.chat.ChatHistory

public final class ChatHistory extends Object
An in-memory store of all chat messages processed during the current server session.

Messages are addressable by their auto-assigned integer ID and can be looked up by channel, sender, or content fragment. The history is accessed via ChatManager#history.

  • Constructor Details

    • ChatHistory

      public ChatHistory()
  • Method Details

    • register

      Records a new message in the history.
      Parameters:
      messageContext - the pre-processed message context
      finalMessage - the fully rendered component that was sent to players
      Returns:
      the newly created registered context, including its assigned ID
    • getById

      Returns the message with the given ID, or null if not found.
      Parameters:
      id - the message ID
      Returns:
      the registered context, or null
    • canDelete

      public boolean canDelete(SocialMessageContext context)
      Returns true if the message can be deleted from the client due to having a signed message attached.
      Parameters:
      context - the message context to check
      Returns:
      true if deletion is possible
    • delete

      public void delete(SocialRegisteredMessageContext context)
      Marks a message as deleted for all online players and replaces its stored component with a red "N/A" placeholder.
      Parameters:
      context - the message to delete
    • get

      Returns all messages in the history.
      Returns:
      an unordered list of all stored messages
    • getByChannel

      Returns all messages sent in a specific channel.
      Parameters:
      channel - the channel to filter by
      Returns:
      the messages sent in that channel
    • getByUser

      Returns all messages sent by the given user.
      Parameters:
      user - the sender to filter by
      Returns:
      the messages sent by that user
    • getByText

      Returns all messages whose raw text contains the given substring.
      Parameters:
      text - the substring to search for
      Returns:
      the matching messages
    • getThread

      Returns all messages belonging to the same thread as the given message, up to an upper bound.

      A thread includes the root message, all direct replies, and any messages that share the same reply ID.

      Parameters:
      messageContext - the message whose thread should be retrieved
      limit - the maximum number of results
      Returns:
      the thread messages