From d819420811ceadbfef7ef675551fa8a631f0264d Mon Sep 17 00:00:00 2001 From: kraftwerk28 Date: Fri, 2 Jul 2021 12:22:27 +0300 Subject: [PATCH] NPE bug fix --- .../kotlin/org/kraftwerk28/spigot_tg_bridge/TgBot.kt | 9 +++++---- src/main/resources/plugin.yml | 2 +- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/src/main/kotlin/org/kraftwerk28/spigot_tg_bridge/TgBot.kt b/src/main/kotlin/org/kraftwerk28/spigot_tg_bridge/TgBot.kt index 397254a..ea74914 100644 --- a/src/main/kotlin/org/kraftwerk28/spigot_tg_bridge/TgBot.kt +++ b/src/main/kotlin/org/kraftwerk28/spigot_tg_bridge/TgBot.kt @@ -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) } } @@ -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( diff --git a/src/main/resources/plugin.yml b/src/main/resources/plugin.yml index 787fd14..cb3e5d9 100644 --- a/src/main/resources/plugin.yml +++ b/src/main/resources/plugin.yml @@ -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.