Skip to content

Commit 489114e

Browse files
committed
Add null checks to screenshotLine
1 parent c5fc085 commit 489114e

1 file changed

Lines changed: 15 additions & 1 deletion

File tree

src/main/kotlin/org/polyfrost/chatting/Chatting.kt

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -213,11 +213,25 @@ object Chatting {
213213
return ChattingConfig.chatWindow.customWidth
214214
}
215215

216-
fun screenshotLine(line: ChatLine): BufferedImage? {
216+
fun screenshotLine(line: ChatLine?): BufferedImage? {
217+
if (line == null || line !is ChatLineHook) {
218+
Notifications.INSTANCE.send("Chatting", "No chat line provided.")
219+
return null
220+
}
221+
217222
return screenshot(
218223
linkedMapOf<ChatLine, String>().also { map ->
219224
val fullMessage = (line as ChatLineHook).`chatting$getFullMessage`()
225+
if (fullMessage == null) {
226+
Notifications.INSTANCE.send("Chatting", "No full message found for the provided chat line.")
227+
return null
228+
}
229+
220230
for (chatLine in (mc.ingameGUI.chatGUI as GuiNewChatAccessor).drawnChatLines) {
231+
if (chatLine == null || chatLine !is ChatLineHook) {
232+
continue
233+
}
234+
221235
if ((chatLine as ChatLineHook).`chatting$getFullMessage`() == fullMessage) {
222236
map[chatLine] = chatLine.chatComponent.formattedText
223237
}

0 commit comments

Comments
 (0)