mirror of
https://github.com/jie65535/JGrasscutterCommand.git
synced 2025-10-16 17:25:47 +08:00
Fix default config issue (remove /
prefix)
Fix public command not handling aliases
This commit is contained in:
@@ -105,18 +105,9 @@ object JGrasscutterCommand : KotlinPlugin(
|
||||
// 处理执行游戏命令
|
||||
else if (message.startsWith(PluginConfig.commandPrefix)) {
|
||||
var command = message.removePrefix(PluginConfig.commandPrefix).trim()
|
||||
if (command.isEmpty()) {
|
||||
if (command.isEmpty() || (command[0] == '/' && command.length == 1)) {
|
||||
return@subscribeAlways
|
||||
}
|
||||
// 检查是否使用别名
|
||||
val t = PluginConfig.commandAlias[command]
|
||||
if (!t.isNullOrEmpty()) command = t
|
||||
// 如果是斜杠开头,则移除斜杠,在控制台执行不需要斜杠
|
||||
if (command[0] == '/') {
|
||||
command = command.substring(1)
|
||||
if (command.isEmpty())
|
||||
return@subscribeAlways
|
||||
}
|
||||
|
||||
// 执行的用户
|
||||
var user: User? = null
|
||||
@@ -142,6 +133,12 @@ object JGrasscutterCommand : KotlinPlugin(
|
||||
user.token
|
||||
}
|
||||
}
|
||||
// 检查是否使用别名
|
||||
val t = PluginConfig.commandAlias[command]
|
||||
if (!t.isNullOrEmpty()) command = t
|
||||
// 如果是斜杠开头,则移除斜杠,在控制台执行不需要斜杠
|
||||
if (command[0] == '/') command = command.substring(1)
|
||||
|
||||
try {
|
||||
// 调用接口执行命令
|
||||
val response = OpenCommandApi.runCommand(server.address, token, command)
|
||||
|
@@ -36,22 +36,22 @@ object PluginConfig : AutoSavePluginConfig("config") {
|
||||
|
||||
@ValueDescription("命令别名")
|
||||
val commandAlias: MutableMap<String, String> by value(mutableMapOf(
|
||||
"无敌" to "/prop god on",
|
||||
"关闭无敌" to "/prop god off",
|
||||
"无限体力" to "/prop ns on",
|
||||
"关闭无限体力" to "/prop ns off",
|
||||
"无限能量" to "/prop ue on",
|
||||
"关闭无限能量" to "/prop ue off",
|
||||
"点亮地图" to "/prop unlockmap 1",
|
||||
"解锁地图" to "/prop unlockmap 1",
|
||||
"位置" to "/pos",
|
||||
"坐标" to "/pos",
|
||||
"无敌" to "prop god on",
|
||||
"关闭无敌" to "prop god off",
|
||||
"无限体力" to "prop ns on",
|
||||
"关闭无限体力" to "prop ns off",
|
||||
"无限能量" to "prop ue on",
|
||||
"关闭无限能量" to "prop ue off",
|
||||
"点亮地图" to "prop unlockmap 1",
|
||||
"解锁地图" to "prop unlockmap 1",
|
||||
"位置" to "pos",
|
||||
"坐标" to "pos",
|
||||
|
||||
// TODO ...
|
||||
))
|
||||
|
||||
@ValueDescription("公开命令,无需绑定账号也可以执行(可用别名)(必须绑定了控制台令牌才可使用)")
|
||||
val publicCommands: MutableSet<String> by value(mutableSetOf(
|
||||
"/list", "/list uid"
|
||||
"list", "list uid"
|
||||
))
|
||||
}
|
Reference in New Issue
Block a user