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