Skip to content

ChatHistoryManager ​

com.jsmacrosce.jsmacros.client.api.classes.inventory.ChatHistoryManager

Since1.6.0

Manages received chat scrollback and sent-message history. Reads and list mutations run inline on the client thread or from a thread joined to it; otherwise they queue on the client thread.
Value-returning reads and most mutations wait for their queued work, but a joined caller cannot wait without deadlocking. Inserting a received line and rebuilding the visible chat touch the font, so they run inline only on the client thread and are queued without waiting elsewhere.
getSent() returns the live sent-history list, so changes to it affect the chat component directly.

js
const history = Chat.getHistory();  
Chat.log(`${history.getRecvCount()} lines in the scrollback`);  
const last = history.getRecvLines();  
if (last.size() > 0) {
  const newest = last.get(last.size() - 1);  
  Chat.log(`the newest is ${newest.getText().getString()}, on tick ${newest.getCreationTick()}`);  
}

Constructors ​

new ChatHistoryManager ​

new ChatHistoryManager(ChatComponent hud)#
Manages the received and sent history of the supplied chat component. FChat.getHistory() obtains a manager for Minecraft's chat component; this constructor stores the supplied component without copying or changing its history.

Parameters:

  • hud: chat component whose history is managed

Methods ​

clearRecv ​

clearRecv(): voidSince1.6.0#
Clears the received-message history without waiting for queued off-thread work to finish.
clearRecv(boolean await): voidSince1.6.0#
Clears the received-message history. Off-thread work is queued; set await to true to wait for it to finish.

Parameters:

  • await: whether to wait for queued work to finish

clearSent ​

clearSent(): voidSince1.6.0#
Clears the sent-message history without waiting for queued off-thread work to finish.
clearSent(boolean await): voidSince1.6.0#
Clears the sent-message history. Off-thread work is queued; set await to true to wait for it to finish.

Parameters:

  • await: whether to wait for queued work to finish

getRecvCount ​

getRecvCount(): intSince1.8.4#
Returns: the number of received messages in the chat history

getRecvLine ​

getRecvLine(int index): ChatHudLineHelperSince1.6.0#

Parameters:

  • index: zero-based index in the received-message history
Returns: the received message at that index

getRecvLines ​

getRecvLines(): List<ChatHudLineHelper>Since1.8.4#
Returns: a new list of wrappers for all received messages

getSent ​

getSent(): List<String>Since1.6.0#
Returns: the live sent-message history list; modifying it changes the chat component's list

insertRecvText ​

insertRecvText(int index, TextHelper line): voidSince1.6.0#
Inserts a chat line at the specified history index. On the client thread the insertion happens immediately; other calls queue it on that thread without waiting.

Parameters:

  • index: history position at which to insert the line
  • line: the chat line to insert
insertRecvText(int index, TextHelper line, int timeTicks): voidSince1.6.0#
Inserts a chat line at the specified history index. On the client thread the insertion happens immediately; other calls queue it on that thread without waiting. The timeTicks argument is currently unused. Call refreshVisible() to update the visible chat after the insertion.

Parameters:

  • index: history position at which to insert the line
  • line: the chat line to insert
  • timeTicks: currently unused
insertRecvText(int index, TextHelper line, int timeTicks, boolean await): voidSince1.6.0#
Inserts a chat line at the specified history index. On the client thread the insertion happens immediately. Other calls queue the insertion on the client thread and wait only when await is true; a thread that the client is already waiting on, such as a joined callback, cannot wait without deadlocking, so the insertion is queued and this call returns. The timeTicks argument is currently unused.

Parameters:

  • index: history position at which to insert the line
  • line: the chat line to insert
  • timeTicks: currently unused
  • await: whether to wait for a queued insertion to finish

refreshVisible ​

refreshVisible(): voidSince1.6.0#
Rebuilds the visible chat view from the received-message history. On the client thread the rebuild happens immediately; other calls queue it without waiting.
refreshVisible(boolean await): voidSince1.6.0#
Rebuilds the visible chat view from the received-message history. On the client thread the rebuild happens immediately. Other calls queue it and wait only when await is true; a thread that the client is already waiting on, such as a joined callback, cannot wait without deadlocking, so the rebuild is queued and this call returns.

Parameters:

  • await: whether to wait for queued work to finish

removeRecvText ​

removeRecvText(int index): voidSince1.6.0#

Parameters:

  • index: zero-based received-message history index to remove
removeRecvText(int index, boolean await): voidSince1.6.0#
Removes the received message at the specified history index. Off-thread removal is queued; set await to true to wait for it to finish.

Parameters:

  • index: zero-based received-message history index to remove
  • await: whether to wait for queued removal to finish

removeRecvTextMatching ​

removeRecvTextMatching(TextHelper text): voidSince1.6.0#

Parameters:

  • text: text whose exact raw value is matched against received messages
removeRecvTextMatching(TextHelper text, boolean await): voidSince1.6.0#
Removes received messages whose raw content equals text. Off-thread removal is queued; set await to true to wait for it to finish.

Parameters:

  • text: text whose exact raw value is matched against received messages
  • await: whether to wait for queued removal to finish

removeRecvTextMatchingFilter ​

removeRecvTextMatchingFilter(MethodWrapper<ChatHudLineHelper, Object, Boolean, ?> filter): voidSince1.6.0#
Removes received messages for which filter returns true. Off-thread removal is queued without waiting for it to finish.

Parameters:

  • filter: predicate applied to each received message
removeRecvTextMatchingFilter(MethodWrapper<ChatHudLineHelper, Object, Boolean, ?> filter, boolean await): voidSince1.6.0#
Removes received messages for which filter returns true. Off-thread removal is queued; set await to true to wait for it to finish.

Parameters:

  • filter: predicate applied to each received message
  • await: whether to wait for queued removal to finish