fix NPE in kotlin.. and several smaller issues

This commit is contained in:
nikky 2018-05-24 19:51:06 +02:00
parent dd07bdd386
commit e652a27a06
3 changed files with 6 additions and 5 deletions

View File

@ -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

View File

@ -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
)

View File

@ -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)