required

inline fun <S, B1 : ArgumentBuilder<S, *>, B2 : ArgumentBuilder<S, *>, D1 : ArgumentDescriptor<*>, D2 : ArgumentDescriptor<*>> ArgumentBuilder<S, *>.required(    first: ArgumentConstructor<S, B1, D1>,     second: ArgumentConstructor<S, B2, D2>,     action: B2.(ArgumentAccessor<S, D1>, ArgumentAccessor<S, D2>) -> Unit)
inline fun <S, B1 : ArgumentBuilder<S, *>, B2 : ArgumentBuilder<S, *>, B3 : ArgumentBuilder<S, *>, D1 : ArgumentDescriptor<*>, D2 : ArgumentDescriptor<*>, D3 : ArgumentDescriptor<*>> ArgumentBuilder<S, *>.required(    first: ArgumentConstructor<S, B1, D1>,     second: ArgumentConstructor<S, B2, D2>,     third: ArgumentConstructor<S, B3, D3>,     action: B3.(ArgumentAccessor<S, D1>, ArgumentAccessor<S, D2>, ArgumentAccessor<S, D3>) -> Unit)

Shorthand allowing registering multiple required arguments at once, with no branches between them.

Author

Cypher121

Samples

import com.mojang.brigadier.CommandDispatcher
import net.minecraft.command.argument.PosArgument
import net.minecraft.command.argument.Vec3ArgumentType
import net.minecraft.network.MessageType
import net.minecraft.server.command.ServerCommandSource
import net.minecraft.text.Text
import net.minecraft.util.math.Vec3d
import org.quiltmc.qkl.wrapper.minecraft.brigadier.*
import org.quiltmc.qkl.wrapper.minecraft.brigadier.argument.*
import org.quiltmc.qkl.wrapper.minecraft.brigadier.util.entity
import org.quiltmc.qkl.wrapper.minecraft.brigadier.util.required
import org.quiltmc.qkl.wrapper.minecraft.brigadier.util.sendFeedback
import org.quiltmc.qkl.wrapper.minecraft.brigadier.util.server
import kotlin.random.Random
fun main() { 
   //sampleStart 
   dispatcher.register("repeat") {
    required(string("string"), integer("times")) { getString, getTimes ->
        executeWithResult {
            val times = getTimes().value()

            if (times % 2 == 1) {
                CommandResult.failure(Text.literal("times must be even"))
            } else {
                repeat(times) {
                    println(getString().value())
                }

                CommandResult.success(times)
            }
        }
    }
} 
   //sampleEnd
}