aboutsummaryrefslogtreecommitdiff
path: root/src/main/kotlin/moe/nea/notenoughupdates/commands/dsl.kt
diff options
context:
space:
mode:
authornea <nea@nea.moe>2023-01-20 04:37:33 +0100
committernea <nea@nea.moe>2023-01-20 04:37:33 +0100
commit81b5f58574d5ea9116f4ef0bb0c0e095f83e21a0 (patch)
tree3a96bfa2da128b6672dcdb77e707c81f9fab93b9 /src/main/kotlin/moe/nea/notenoughupdates/commands/dsl.kt
parentf85c449ed586c7ced780423943e55bfa5abaeb0f (diff)
downloadFirmament-81b5f58574d5ea9116f4ef0bb0c0e095f83e21a0.tar.gz
Firmament-81b5f58574d5ea9116f4ef0bb0c0e095f83e21a0.tar.bz2
Firmament-81b5f58574d5ea9116f4ef0bb0c0e095f83e21a0.zip
Restructure commands
Diffstat (limited to 'src/main/kotlin/moe/nea/notenoughupdates/commands/dsl.kt')
-rw-r--r--src/main/kotlin/moe/nea/notenoughupdates/commands/dsl.kt10
1 files changed, 8 insertions, 2 deletions
diff --git a/src/main/kotlin/moe/nea/notenoughupdates/commands/dsl.kt b/src/main/kotlin/moe/nea/notenoughupdates/commands/dsl.kt
index c21eab8..6190d88 100644
--- a/src/main/kotlin/moe/nea/notenoughupdates/commands/dsl.kt
+++ b/src/main/kotlin/moe/nea/notenoughupdates/commands/dsl.kt
@@ -5,13 +5,19 @@ import com.mojang.brigadier.builder.ArgumentBuilder
import com.mojang.brigadier.builder.LiteralArgumentBuilder
import com.mojang.brigadier.builder.RequiredArgumentBuilder
import com.mojang.brigadier.context.CommandContext
-import moe.nea.notenoughupdates.util.iterate
-import net.fabricmc.fabric.api.client.command.v2.FabricClientCommandSource
import java.lang.reflect.ParameterizedType
+import net.fabricmc.fabric.api.client.command.v2.FabricClientCommandSource
+import moe.nea.notenoughupdates.util.iterate
typealias DefaultSource = FabricClientCommandSource
+
+inline val <T : CommandContext<*>> T.context get() = this
+operator fun <T : Any, C : CommandContext<*>> C.get(arg: TypeSafeArg<T>): T {
+ return arg.get(this)
+}
+
fun literal(
name: String,
block: LiteralArgumentBuilder<DefaultSource>.() -> Unit