From e652a27a06d4e8f87fede122cccdcf3ac67e1260 Mon Sep 17 00:00:00 2001 From: nikky Date: Thu, 24 May 2018 19:51:06 +0200 Subject: [PATCH] fix NPE in kotlin.. and several smaller issues --- .../main/kotlin/matterlink/bridge/command/CustomCommand.kt | 5 +++-- core/src/main/kotlin/matterlink/config/CommandConfig.kt | 2 +- .../src/main/kotlin/matterlink/handlers/ServerChatHandler.kt | 4 ++-- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/core/src/main/kotlin/matterlink/bridge/command/CustomCommand.kt b/core/src/main/kotlin/matterlink/bridge/command/CustomCommand.kt index 22e965b..6f22d63 100644 --- a/core/src/main/kotlin/matterlink/bridge/command/CustomCommand.kt +++ b/core/src/main/kotlin/matterlink/bridge/command/CustomCommand.kt @@ -5,6 +5,7 @@ import matterlink.bridge.MessageHandlerInst import matterlink.handlers.TickHandler import matterlink.instance import matterlink.lazyFormat +import matterlink.stripColor data class CustomCommand( val type: CommandType = CommandType.RESPONSE, @@ -34,7 +35,7 @@ data class CustomCommand( if (!canExecute(userId, server)) { MessageHandlerInst.transmit( ApiMessage( - text = "$user is not permitted to perform command: $alias" + text = "$user is not permitted to perform command: $alias".stripColor ) ) return false @@ -53,7 +54,7 @@ data class CustomCommand( CommandType.RESPONSE -> { MessageHandlerInst.transmit( ApiMessage( - text = (response?.lazyFormat(getReplacements(user, userId, server, args)) ?: "") + text = (response?.lazyFormat(getReplacements(user, userId, server, args))?.stripColor ?: "") ) ) true diff --git a/core/src/main/kotlin/matterlink/config/CommandConfig.kt b/core/src/main/kotlin/matterlink/config/CommandConfig.kt index 058ebe3..b55c3fb 100644 --- a/core/src/main/kotlin/matterlink/config/CommandConfig.kt +++ b/core/src/main/kotlin/matterlink/config/CommandConfig.kt @@ -60,7 +60,7 @@ object CommandConfig { execute = "", permLevel = 1.0, help = "Execute any command as OP, be careful with this one", - allowArgs = false, + allowArgs = true, execOp = true, defaultCommand = true ) diff --git a/core/src/main/kotlin/matterlink/handlers/ServerChatHandler.kt b/core/src/main/kotlin/matterlink/handlers/ServerChatHandler.kt index 249ff1e..0c465cf 100644 --- a/core/src/main/kotlin/matterlink/handlers/ServerChatHandler.kt +++ b/core/src/main/kotlin/matterlink/handlers/ServerChatHandler.kt @@ -15,9 +15,9 @@ object ServerChatHandler { fun writeIncomingToChat() { if (MessageHandlerInst.queue.isNotEmpty()) instance.debug("incoming: " + MessageHandlerInst.queue.toString()) - val nextMessage = MessageHandlerInst.queue.poll() + val nextMessage = MessageHandlerInst.queue.poll() ?: null - if (nextMessage.gateway == cfg.connect.gateway) { + if (nextMessage?.gateway == cfg.connect.gateway) { if (!nextMessage.text.isBlank()) { val message = when (nextMessage.event) { "user_action" -> nextMessage.format(cfg.incoming.action)