Skip to content

Commit

Permalink
NPE bug fix
Browse files Browse the repository at this point in the history
  • Loading branch information
kraftwerk28 committed Jul 2, 2021
1 parent a8bf75a commit d819420
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
9 changes: 5 additions & 4 deletions src/main/kotlin/org/kraftwerk28/spigot_tg_bridge/TgBot.kt
Original file line number Diff line number Diff line change
Expand Up @@ -103,9 +103,9 @@ class TgBot(
update.message?.text?.let {
commandRegex.matchEntire(it)?.groupValues?.let {
commandMap[it[1]]?.let { it(update) }
} ?: run {
onTextHandler(update)
}
} ?: run {
onTextHandler(update)
}
}

Expand Down Expand Up @@ -185,9 +185,10 @@ class TgBot(
}

private suspend fun onTextHandler(update: TgApiService.Update) {
if (!config.logFromTGtoMC) return
val msg = update.message!!
plugin.sendMessageToMinecraft(msg.text!!, msg.from!!.rawUserMention())
if (!config.logFromTGtoMC || msg.from == null)
return
plugin.sendMessageToMinecraft(msg.text!!, msg.from.rawUserMention())
}

private fun formatMsgFromMinecraft(
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/plugin.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: SpigotTGBridge
version: "0.16"
version: "0.17"
api-version: "1.15"
main: org.kraftwerk28.spigot_tg_bridge.Plugin
description: Telegram <-> Minecraft communication plugin for Spigot.
Expand Down

0 comments on commit d819420

Please sign in to comment.