Skip to content

Commit

Permalink
fix: certain arguments not working without suggests, even if listSugg…
Browse files Browse the repository at this point in the history
…estion is defined in ArgumentType
  • Loading branch information
Boy0000 committed Oct 13, 2024
1 parent 1ce5713 commit 3986336
Showing 1 changed file with 11 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -35,8 +34,18 @@ open class IdoCommand(
return IdoArgumentBuilder(this) { provider.getSuggestions(context, suggestions) }
}

operator fun <T> ArgumentType<T>.provideDelegate(t: T, property: KProperty<*>): IdoArgument<T> {
operator fun <T> ArgumentType<T>.provideDelegate(thisRef: Any?, property: KProperty<*>): IdoArgument<T> {
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)
}

Expand Down

0 comments on commit 3986336

Please sign in to comment.