feat: bootの対応
This commit is contained in:
parent
3671948bfe
commit
e0613cd052
|
|
@ -23,6 +23,20 @@ object WordArgumentType : KommandArgumentType<String> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
object BooleanArgumentType : KommandArgumentType<Boolean> {
|
||||||
|
override fun parse(input: String, context: KommandContext): ArgumentParseResult<Boolean> {
|
||||||
|
val lower = input.lowercase()
|
||||||
|
return when (lower) {
|
||||||
|
"true" -> ArgumentParseResult.Success(true)
|
||||||
|
"false" -> ArgumentParseResult.Success(false)
|
||||||
|
else -> ArgumentParseResult.Failure("Expected true/false but got '$input'")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun suggestions(context: KommandContext, prefix: String): List<String> =
|
||||||
|
listOf("true", "false").filter { it.startsWith(prefix, ignoreCase = true) }
|
||||||
|
}
|
||||||
|
|
||||||
class IntegerArgumentType(
|
class IntegerArgumentType(
|
||||||
val min: Int? = null,
|
val min: Int? = null,
|
||||||
val max: Int? = null
|
val max: Int? = null
|
||||||
|
|
|
||||||
|
|
@ -147,6 +147,11 @@ abstract class BranchScope internal constructor(
|
||||||
block: ValueBuilder<Double>.() -> Unit = {}
|
block: ValueBuilder<Double>.() -> Unit = {}
|
||||||
) = argument(name, FloatArgumentType(min, max), block)
|
) = argument(name, FloatArgumentType(min, max), block)
|
||||||
|
|
||||||
|
fun bool(
|
||||||
|
name: String,
|
||||||
|
block: ValueBuilder<Boolean>.() -> Unit = {}
|
||||||
|
) = argument(name, BooleanArgumentType, block)
|
||||||
|
|
||||||
fun player(
|
fun player(
|
||||||
name: String,
|
name: String,
|
||||||
allowSelectors: Boolean = true,
|
allowSelectors: Boolean = true,
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user