Kommand

Command DSL for PaperMC Plugin (Brigadier)
-
Features
- ๋ช
๋ น์ด ๋ถ๊ธฐ ์ง์
- ์ธ์ ๋ถ์(Parsing)
- ๋ช
๋ น์ด ์ ์ ์ง์ (TabComplete)
-
Supported minecraft versions
- 1.17.1
- 1.18
- 1.18.1
- 1.18.2
- 1.19
- 1.19.1
- 1.19.2
- 1.19.3
- 1.19.4
- 1.20
- 1.20.1
Paper์๋ ๋ช
๋ น์ด ์คํ์ ์ํ ํ๋ ์์ํฌ๊ฐ ์์ต๋๋ค.
๋ค๋ฅธ ํ๋ ์์ํฌ๋ฅผ ์ฌ์ฉํ์ง ์๊ณ ๋
๋ฆฝํ์ผ๋ก ๋ช
๋ น์ด ์คํ ์ฝ๋๋ฅผ ์์ฑ์ ๋ค์๊ณผ ๊ฐ์ ํจํด์ผ๋ก ์์ฑํ๊ฒ ๋ฉ๋๋ค.
class CommandDispatcher : CommandExecutor {
...
override fun onCommand(...) {
val commandName = args[0]
if ("first".equals(commandName, true)) {
} else if ("second".equals(commandName, true)) {
} else {
}
}
}
...
์์ ๊ฐ์ ์ฝ๋๋ ๋ช
๋ น๋ฌธ์ด ์ ์๋ ๊ฐ๊ฒฐํ์ง๋ง, ๋ฐ๋ผ๋ถ๋ ์ธ์๋ ์์๊ฐ ๋์ด๋๋ฉด ์ฝ๋๊ฐ ๋งค์ฐ ์ง์ ๋ถํด์ง๊ณ ๋๋ฒ๊น
์๋ ์ด๋ ค์์ ๊ฒช๊ฒ๋ฉ๋๋ค.
๊ทธ๋์ ๋ช
๋ น ์ฒ๋ฆฌ๋ ์ ๊ฒฝ์ฐ์ง ์๊ณ ์ต์ข
์คํ์ฝ๋๋ง ์์ฑ ํ ์ ์๋ ํ๋ ์์ํฌ๊ฐ ํ์ํด์ก์ต๋๋ค.
Kommand๋ ์์ ๊ฐ์ ๋ฌธ์ ๋ฅผ ํด๊ฒฐํ๊ณ ๋ช
๋ น๋ฌธ์ ๋ณด๋ค ์ง๊ด์ ์ธ ์ฝ๋์์ฑ์ ์ํ DSL์ ์ ๊ณตํฉ๋๋ค.
์๋์ ๊ฐ์ ๋ช
๋ น ์ฒด๊ณ๊ฐ ์๋ค๊ณ ์๊ฐํด๋ด
์๋ค.
- user
- create <username>
- modify <user>
- name <newName>
- tag <newTag>
๋ค์ ์ฝ๋๋ Kommand์ DSL์ ์ฌ์ฉํ ์ฝ๋์
๋๋ค.
kommand {
register("user") {
then("create") {
then("name" to string()) {
executes { context ->
val name: String by context
createUser(name)
}
}
}
"modify"("user" to dynamic { ... }) {
"name"("newName" to string()) {
executes { context ->
val user: User by context
val newName: String = it["newName"]
setUserName(user, newName)
}
}
"tag"("newTag" to string()) {
executes {
setUserTag(it["user"], it["newTag"])
}
}
}
}
}
๋ถ๊ธฐ๋ฌธ์ ์ง์ ์์ฑํ์ง ์๊ณ ๋ ๋ช
๋ น์ด๋ฅผ ์คํ ํ ์ ์๋ ์ฝ๋๊ฐ ์์ฑ๋์์ต๋๋ค.
์ฌ์ฉ์๊ฐ ๋ช
๋ น๋ฌธ์ ์๋ง๊ฒ ์์ฑํ๋ฉด executes๋ธ๋ก ๋ด์ ์ฝ๋๊ฐ ์คํ๋ฉ๋๋ค.
Gradle
repositories {
mavenCentral()
}
dependencies {
implementation("io.github.monun:kommand-api:<version>")
}
plugin.yml
name: ...
version: ...
main: ...
libraries:
- io.github.monun:kommand-core:<version>
NOTE
- ๋ผ์ด์ผ์ค๋ GPL-3.0์ด๋ฉฐ ๋ณ๊ฒฝ ํน์ ์ญ์ ๋ฅผ ๊ธํฉ๋๋ค.
Contributors
- patrick-choe
- maven central ๋ฐฐํฌ
- ๊ธฐ๋ณธ Argument ์ผ๋ถ ์์ฑ
- mojang map ์ด์ฉ ํ๊ฒฝ ๊ตฌ์ถ
- Jhyub
- DslMarker๋ฅผ ์ด์ฉํ DSL ๊ท์น ํฅ์
- pikokr