|
1 | 1 | package com.mairwunnx.projectessentials.core.impl.commands |
2 | 2 |
|
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 |
5 | 4 | import com.mairwunnx.projectessentials.core.impl.configurations.GeneralConfiguration |
6 | 5 | import com.mojang.brigadier.arguments.StringArgumentType |
7 | 6 | import com.mojang.brigadier.builder.LiteralArgumentBuilder |
8 | | -import com.mojang.brigadier.builder.LiteralArgumentBuilder.literal |
9 | 7 | import net.minecraft.command.CommandSource |
10 | 8 | import net.minecraft.command.Commands |
| 9 | +import net.minecraft.command.ISuggestionProvider |
11 | 10 |
|
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( |
19 | 22 | 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 | + } |
23 | 26 | ) |
24 | 27 | ) |
25 | 28 | ) |
0 commit comments