From 39863366ce56780e2408401d64423964551c64f5 Mon Sep 17 00:00:00 2001 From: Boy Date: Sun, 13 Oct 2024 20:12:15 +0200 Subject: [PATCH] fix: certain arguments not working without suggests, even if listSuggestion is defined in ArgumentType --- .../idofront/commands/brigadier/IdoCommand.kt | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/idofront-commands/src/main/kotlin/com/mineinabyss/idofront/commands/brigadier/IdoCommand.kt b/idofront-commands/src/main/kotlin/com/mineinabyss/idofront/commands/brigadier/IdoCommand.kt index 47832b4..af3d096 100644 --- a/idofront-commands/src/main/kotlin/com/mineinabyss/idofront/commands/brigadier/IdoCommand.kt +++ b/idofront-commands/src/main/kotlin/com/mineinabyss/idofront/commands/brigadier/IdoCommand.kt @@ -10,7 +10,6 @@ import com.mojang.brigadier.suggestion.SuggestionProvider import com.mojang.brigadier.tree.LiteralCommandNode import io.papermc.paper.command.brigadier.CommandSourceStack import io.papermc.paper.command.brigadier.Commands -import io.papermc.paper.command.brigadier.argument.ArgumentTypes import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.async import kotlinx.coroutines.future.asCompletableFuture @@ -35,8 +34,18 @@ open class IdoCommand( return IdoArgumentBuilder(this) { provider.getSuggestions(context, suggestions) } } - operator fun ArgumentType.provideDelegate(t: T, property: KProperty<*>): IdoArgument { + operator fun ArgumentType.provideDelegate(thisRef: Any?, property: KProperty<*>): IdoArgument { add(RenderStep.Builder(Commands.argument(property.name, this))) + + // If no suggestions are provided, use the default listSuggestions method + add(RenderStep.Builder(Commands.argument(property.name, this).apply { + suggests { context, builder -> + // Call the default listSuggestions method on the ArgumentType + this@provideDelegate.listSuggestions(context, builder) + } + })) + + // Return an IdoArgument object with the argument's name return IdoArgument(property.name) }