Commands can be disabled now
This commit is contained in:
parent
6961d34f17
commit
f68439cd13
|
@ -37,7 +37,8 @@ class MatterLinkConfig(file: File) {
|
|||
)
|
||||
|
||||
data class CommandOptions(
|
||||
val prefix: String
|
||||
val prefix: String,
|
||||
val enable: Boolean
|
||||
)
|
||||
|
||||
init {
|
||||
|
@ -75,6 +76,12 @@ class MatterLinkConfig(file: File) {
|
|||
|
||||
config.addCustomCategoryComment(CATEGORY_COMMAND,"User commands")
|
||||
command = CommandOptions(
|
||||
enable = config.getBoolean(
|
||||
"enable",
|
||||
CATEGORY_COMMAND,
|
||||
true,
|
||||
"Enable MC bridge commands"
|
||||
),
|
||||
prefix = config.getString(
|
||||
"commandPrefix",
|
||||
CATEGORY_COMMAND,
|
||||
|
|
|
@ -21,7 +21,7 @@ class ServerChatHelper {
|
|||
val message = when (nextMessage.event) {
|
||||
"user_action" -> nextMessage.format(cfg!!.formatting.action)
|
||||
"" -> {
|
||||
BridgeCommand.handleCommand(nextMessage.text)
|
||||
if (BridgeCommand.handleCommand(nextMessage.text)) return
|
||||
nextMessage.format(cfg!!.formatting.chat)
|
||||
}
|
||||
"join_leave" -> nextMessage.format(cfg!!.formatting.joinLeave)
|
||||
|
|
|
@ -11,6 +11,7 @@ class BridgeCommand(val name: String, command: (String) -> Boolean, val help: St
|
|||
private val commandMap: HashMap<String, BridgeCommand> = HashMap()
|
||||
|
||||
fun handleCommand(input: String): Boolean {
|
||||
if (!cfg!!.command.enable) return false
|
||||
if (input[0] != cfg!!.command.prefix[0] || input.length < 2) return false
|
||||
|
||||
val cmd = input.substring(1).split(delimiters = ' ', ignoreCase = false, limit = 2)
|
||||
|
|
Loading…
Reference in New Issue