Skip to content
No description, website, or topics provided.
Kotlin
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
src/main/java/de/phyrone/brig/wrapper
.gitignore
.travis.yml
README.md
pom.xml

README.md

Build Status

Brigardier-Kotlin

This is an Extension for Mojangs Brigadier with Kotlin

Example with "String" as source

val dispatcher = CommandDispatcher<String>()
dispatcher.liternal("printString") {
   executes {
      println(this)
      return@executes 0
   }
}

Example

    //Command is a Test Interface (just ignore it)
    val dispatcher = CommandDispatcher<Command>()
    dispatcher.literal("stop") {
        executes {
            //exit
            exitProcess(0)
        }
    }
    dispatcher.literal("help") {
        runs {
            //"runs" Always return 0
            sender.sendMessage("All Commands:")
            dispatcher.getAllUsage(dispatcher.root, this, false).forEach {
                sender.sendMessage("> $it")
            }
        }
        argument("startswith", StringArgument) {
            runs {
                sender.sendMessage("All Commands:")
                //get the argument
                val startsWthInput = it.getArgument<String>("startswith")
                dispatcher.getAllUsage(dispatcher.root, this, false).forEach { line ->
                    if (line.startsWith(startsWthInput, true))
                        sender.sendMessage("> $line")
                }
            }
        }
    }
    dispatcher.literal("foo") {
        literal("bar") {
            literal("moreDeepFoo") {
                literal("howMuchMore") {
                    executes {
                        sender.sendMessage("to infinity")
                        return@executes 0
                    }
                }
            }
        }
    }
You can’t perform that action at this time.