ChatHistoryManager
com.jsmacrosce.jsmacros.client.api.classes.inventory.ChatHistoryManager
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.
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)#Parameters:
hud: chat component whose history is managed
Methods
clearRecv
await to true to wait for it to finish.Parameters:
await: whether to wait for queued work to finish
clearSent
await to true to wait for it to finish.Parameters:
await: whether to wait for queued work to finish
getRecvCount
getRecvLine
Parameters:
index: zero-based index in the received-message history
getRecvLines
getSent
insertRecvText
Parameters:
index: history position at which to insert the lineline: the chat line to insert
timeTicks argument is currently unused. Call refreshVisible() to update the visible chat after the insertion.Parameters:
index: history position at which to insert the lineline: the chat line to inserttimeTicks: currently unused
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 lineline: the chat line to inserttimeTicks: currently unusedawait: whether to wait for a queued insertion to finish
refreshVisible
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
Parameters:
index: zero-based received-message history index to remove
await to true to wait for it to finish.Parameters:
index: zero-based received-message history index to removeawait: whether to wait for queued removal to finish
removeRecvTextMatching
Parameters:
text: text whose exact raw value is matched against received messages
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 messagesawait: whether to wait for queued removal to finish
removeRecvTextMatchingFilter
removeRecvTextMatchingFilter(MethodWrapper<ChatHudLineHelper, Object, Boolean, ?> filter): voidSince1.6.0#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#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 messageawait: whether to wait for queued removal to finish