๐Ÿš€ Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more โ†’
Socket
Sign inDemoInstall
Socket

io.github.monun:kommand-api

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

io.github.monun:kommand-api

Kotlin DSL for PaperMC commands

3.1.7
Source
Maven
Version published
Maintainers
1
Source

Kommand

Java Kotlin Gradle Maven Central GitHub YouTube

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)) {
            // first ๋ช…๋ น ์ฒ˜๋ฆฌ
        } else if ("second".equals(commandName, true)) {
            // second ๋ช…๋ น ์ฒ˜๋ฆฌ
        } else {
            // Error
        }
        //when ๋ฌธ์œผ๋กœ๋„ ๊ตฌํ˜„ ๊ฐ€๋Šฅ
    }
}
...

์œ„์™€ ๊ฐ™์€ ์ฝ”๋“œ๋Š” ๋ช…๋ น๋ฌธ์ด ์ ์„๋• ๊ฐ„๊ฒฐํ•˜์ง€๋งŒ, ๋”ฐ๋ผ๋ถ™๋Š” ์ธ์ˆ˜๋‚˜ ์ƒ์ˆ˜๊ฐ€ ๋Š˜์–ด๋‚˜๋ฉด ์ฝ”๋“œ๊ฐ€ ๋งค์šฐ ์ง€์ €๋ถ„ํ•ด์ง€๊ณ  ๋””๋ฒ„๊น…์—๋„ ์–ด๋ ค์›€์„ ๊ฒช๊ฒŒ๋ฉ๋‹ˆ๋‹ค.

๊ทธ๋ž˜์„œ ๋ช…๋ น ์ฒ˜๋ฆฌ๋Š” ์‹ ๊ฒฝ์“ฐ์ง€ ์•Š๊ณ  ์ตœ์ข… ์‹คํ–‰์ฝ”๋“œ๋งŒ ์ž‘์„ฑ ํ•  ์ˆ˜ ์žˆ๋Š” ํ”„๋ ˆ์ž„์›Œํฌ๊ฐ€ ํ•„์š”ํ•ด์กŒ์Šต๋‹ˆ๋‹ค.

Kommand๋Š” ์œ„์™€ ๊ฐ™์€ ๋ฌธ์ œ๋ฅผ ํ•ด๊ฒฐํ•˜๊ณ  ๋ช…๋ น๋ฌธ์„ ๋ณด๋‹ค ์ง๊ด€์ ์ธ ์ฝ”๋“œ์ž‘์„ฑ์„ ์œ„ํ•œ DSL์„ ์ œ๊ณตํ•ฉ๋‹ˆ๋‹ค.

์•„๋ž˜์™€ ๊ฐ™์€ ๋ช…๋ น ์ฒด๊ณ„๊ฐ€ ์žˆ๋‹ค๊ณ  ์ƒ๊ฐํ•ด๋ด…์‹œ๋‹ค.

  • user
    • create <username>
    • modify <user>
      • name <newName>
      • tag <newTag>

๋‹ค์Œ ์ฝ”๋“œ๋Š” Kommand์˜ DSL์„ ์‚ฌ์šฉํ•œ ์ฝ”๋“œ์ž…๋‹ˆ๋‹ค.

//in JavaPlugin
kommand {
    register("user") {
        then("create") {
            then("name" to string()) { //"name"์ด๋ผ๋Š” ์ด๋ฆ„์˜ String์„ ์š”์ฒญํ•ฉ๋‹ˆ๋‹ค.
                executes { context ->
                    val name: String by context
                    createUser(name) //๋ช…๋ น์–ด ์‹คํ–‰ ํ•จ์ˆ˜๋ฅผ ํ†ตํ•ด ์‹คํ–‰
                }
            }
        }
        // ๋น ๋ฅธ ๋ช…๋ น ์ž‘์„ฑ - then ํ•จ์ˆ˜์™€ ๋™์ผ
        "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
    • 1.18.2 ์ง€์›

FAQs

Package last updated on 22 Jul 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts