Matt-MX / KtPaperGui

Declarative GUI focused library for PaperMC. Made for personal use but open source enjoy! :)
Apache License 2.0
28 stars 5 forks source link

String command dsl #16

Closed Matt-MX closed 6 months ago

Matt-MX commented 9 months ago

Implementing a new DSL for command building could be useful.

"/test <player:player> <msg:string...>" {
    val player by argument<Player>()
    val msg by argument<Array<String>>()

    player.sendMessage(!"&7[${source.name} -> Me]" + Component.text(msg))
    source.sendMessage(!"&7[Me -> ${player.name}]" + Component.text(msg))
}

"/foo" {
    "bar" {
        source.sendMessage("Bar")
    }
    "fizz <msg:string...>" {
        val msg by argument<Array<String>>()
        source.sendMessage("Fizz ($msg)")
    } missing {
        source.sendMessage("Argument $argName is required")
    }
}
Matt-MX commented 6 months ago

impl in #21