Package ovh.mythmc.social.api.chat
Class ChatHistory
java.lang.Object
ovh.mythmc.social.api.chat.ChatHistory
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 Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleancanDelete(SocialMessageContext context) Returnstrueif the message can be deleted from the client due to having a signed message attached.voiddelete(SocialRegisteredMessageContext context) Marks a message as deleted for all online players and replaces its stored component with a red"N/A"placeholder.get()Returns all messages in the history.getByChannel(@NotNull ChatChannel channel) Returns all messages sent in a specific channel.Returns the message with the given ID, ornullif not found.Returns all messages whose raw text contains the given substring.getByUser(@NotNull SocialUser user) Returns all messages sent by the given user.getThread(@NotNull SocialRegisteredMessageContext messageContext, int limit) Returns all messages belonging to the same thread as the given message, up to an upper bound.register(@NotNull SocialMessageContext messageContext, @NotNull Component finalMessage) Records a new message in the history.
-
Constructor Details
-
ChatHistory
public ChatHistory()
-
-
Method Details
-
register
public SocialRegisteredMessageContext register(@NotNull @NotNull SocialMessageContext messageContext, @NotNull @NotNull Component finalMessage) Records a new message in the history.- Parameters:
messageContext- the pre-processed message contextfinalMessage- 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, ornullif not found.- Parameters:
id- the message ID- Returns:
- the registered context, or
null
-
canDelete
Returnstrueif the message can be deleted from the client due to having a signed message attached.- Parameters:
context- the message context to check- Returns:
trueif deletion is possible
-
delete
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
public List<SocialRegisteredMessageContext> getThread(@NotNull @NotNull SocialRegisteredMessageContext messageContext, int limit) 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 retrievedlimit- the maximum number of results- Returns:
- the thread messages
-