mirror of
https://github.com/alexcrea/CustomAnvil.git
synced 2026-08-28 08:25:56 +02:00
replace gui to config subcommand
This commit is contained in:
parent
f6f68d1971
commit
4c3b3b09ad
2 changed files with 11 additions and 2 deletions
|
|
@ -20,6 +20,7 @@ class CustomAnvilCommand(plugin: CustomAnvil) : CommandExecutor, TabCompleter {
|
|||
private val helpCommand = HelpExecutor()
|
||||
private val commands = ImmutableMap.of(
|
||||
"gui", editConfigCommand,
|
||||
"config", editConfigCommand,
|
||||
"reload", ReloadExecutor(),
|
||||
"diagnostic", DiagnosticExecutor(),
|
||||
"debug", DebugToggleExecutor(),
|
||||
|
|
@ -42,12 +43,16 @@ class CustomAnvilCommand(plugin: CustomAnvil) : CommandExecutor, TabCompleter {
|
|||
): Boolean {
|
||||
// Find sub command to execute based on the provided command name
|
||||
val subcmd: CASubCommand?
|
||||
val subcmdStr: String
|
||||
|
||||
val newargs: Array<out String>
|
||||
if(args.isEmpty()) {
|
||||
subcmdStr = "config"
|
||||
subcmd = editConfigCommand
|
||||
newargs = args
|
||||
}else {
|
||||
subcmd = commands[args[0].lowercase()]
|
||||
subcmdStr = args[0].lowercase()
|
||||
subcmd = commands[subcmdStr]
|
||||
newargs = args.copyOfRange(1, args.size)
|
||||
}
|
||||
|
||||
|
|
@ -57,7 +62,7 @@ class CustomAnvilCommand(plugin: CustomAnvil) : CommandExecutor, TabCompleter {
|
|||
}
|
||||
|
||||
try {
|
||||
return subcmd.executeCommand(sender, cmd, cmdstr, newargs)
|
||||
return subcmd.executeCommand(sender, cmd, subcmdStr, newargs)
|
||||
} catch (e: Throwable) {
|
||||
MetricsUtil.trackError(e)
|
||||
sender.sendMessage("§cError running this command")
|
||||
|
|
|
|||
|
|
@ -29,6 +29,10 @@ class EditConfigExecutor: CASubCommand() {
|
|||
return false
|
||||
}
|
||||
|
||||
if ("gui".equals(cmdstr, ignoreCase = true)) {
|
||||
sender.sendMessage("§c/ca gui has been moved to /ca config")
|
||||
}
|
||||
|
||||
MainConfigGui.getInstance().show(sender)
|
||||
|
||||
return true
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue