Skip to content

Commit f06f521

Browse files
committed
Auto-complete general settings implemented.
Signed-off-by: Pavel Erokhin (MairwunNx) <MairwunNx@gmail.com>
1 parent d63f3d1 commit f06f521

1 file changed

Lines changed: 16 additions & 13 deletions

File tree

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,28 @@
11
package com.mairwunnx.projectessentials.core.impl.commands
22

3-
import com.mairwunnx.projectessentials.core.api.v1.commands.arguments.StringArrayArgument
4-
import com.mairwunnx.projectessentials.core.api.v1.configuration.ConfigurationAPI
3+
import com.mairwunnx.projectessentials.core.api.v1.configuration.ConfigurationAPI.getConfigurationByName
54
import com.mairwunnx.projectessentials.core.impl.configurations.GeneralConfiguration
65
import com.mojang.brigadier.arguments.StringArgumentType
76
import com.mojang.brigadier.builder.LiteralArgumentBuilder
8-
import com.mojang.brigadier.builder.LiteralArgumentBuilder.literal
97
import net.minecraft.command.CommandSource
108
import net.minecraft.command.Commands
9+
import net.minecraft.command.ISuggestionProvider
1110

12-
fun takeConfigureEssentialsLiteral(): LiteralArgumentBuilder<CommandSource> =
13-
literal<CommandSource>("configure-essentials").then(
14-
Commands.argument("setting", StringArrayArgument.with(
15-
ConfigurationAPI.getConfigurationByName<GeneralConfiguration>(
16-
"general"
17-
).take().keys.map { it.toString() }
18-
)).then(
11+
inline val configureEssentialsLiteral: LiteralArgumentBuilder<CommandSource>
12+
get() = Commands.literal("configure-essentials").then(
13+
Commands.argument(
14+
"setting", StringArgumentType.string()
15+
).suggests { _, builder ->
16+
ISuggestionProvider.suggest(
17+
getConfigurationByName<GeneralConfiguration>(
18+
"general"
19+
).take().keys.map { it as String }, builder
20+
)
21+
}.then(
1922
Commands.literal("set").then(
20-
Commands.argument("value", StringArgumentType.string()).executes(
21-
ConfigureEssentialsCommand::process
22-
)
23+
Commands.argument("value", StringArgumentType.string()).executes {
24+
ConfigureEssentialsCommand.process(it)
25+
}
2326
)
2427
)
2528
)

0 commit comments

Comments
 (0)