fix NPE in kotlin.. and several smaller issues
This commit is contained in:
parent
dd07bdd386
commit
e652a27a06
|
@ -5,6 +5,7 @@ import matterlink.bridge.MessageHandlerInst
|
||||||
import matterlink.handlers.TickHandler
|
import matterlink.handlers.TickHandler
|
||||||
import matterlink.instance
|
import matterlink.instance
|
||||||
import matterlink.lazyFormat
|
import matterlink.lazyFormat
|
||||||
|
import matterlink.stripColor
|
||||||
|
|
||||||
data class CustomCommand(
|
data class CustomCommand(
|
||||||
val type: CommandType = CommandType.RESPONSE,
|
val type: CommandType = CommandType.RESPONSE,
|
||||||
|
@ -34,7 +35,7 @@ data class CustomCommand(
|
||||||
if (!canExecute(userId, server)) {
|
if (!canExecute(userId, server)) {
|
||||||
MessageHandlerInst.transmit(
|
MessageHandlerInst.transmit(
|
||||||
ApiMessage(
|
ApiMessage(
|
||||||
text = "$user is not permitted to perform command: $alias"
|
text = "$user is not permitted to perform command: $alias".stripColor
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
return false
|
return false
|
||||||
|
@ -53,7 +54,7 @@ data class CustomCommand(
|
||||||
CommandType.RESPONSE -> {
|
CommandType.RESPONSE -> {
|
||||||
MessageHandlerInst.transmit(
|
MessageHandlerInst.transmit(
|
||||||
ApiMessage(
|
ApiMessage(
|
||||||
text = (response?.lazyFormat(getReplacements(user, userId, server, args)) ?: "")
|
text = (response?.lazyFormat(getReplacements(user, userId, server, args))?.stripColor ?: "")
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
true
|
true
|
||||||
|
|
|
@ -60,7 +60,7 @@ object CommandConfig {
|
||||||
execute = "",
|
execute = "",
|
||||||
permLevel = 1.0,
|
permLevel = 1.0,
|
||||||
help = "Execute any command as OP, be careful with this one",
|
help = "Execute any command as OP, be careful with this one",
|
||||||
allowArgs = false,
|
allowArgs = true,
|
||||||
execOp = true,
|
execOp = true,
|
||||||
defaultCommand = true
|
defaultCommand = true
|
||||||
)
|
)
|
||||||
|
|
|
@ -15,9 +15,9 @@ object ServerChatHandler {
|
||||||
fun writeIncomingToChat() {
|
fun writeIncomingToChat() {
|
||||||
if (MessageHandlerInst.queue.isNotEmpty())
|
if (MessageHandlerInst.queue.isNotEmpty())
|
||||||
instance.debug("incoming: " + MessageHandlerInst.queue.toString())
|
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()) {
|
if (!nextMessage.text.isBlank()) {
|
||||||
val message = when (nextMessage.event) {
|
val message = when (nextMessage.event) {
|
||||||
"user_action" -> nextMessage.format(cfg.incoming.action)
|
"user_action" -> nextMessage.format(cfg.incoming.action)
|
||||||
|
|
Loading…
Reference in New Issue