Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/alvin0319/kommand-pnx

A library for PowerNukkitX that adds easier usage on Kotlin with DSL support.
https://github.com/alvin0319/kommand-pnx

Last synced: 16 days ago
JSON representation

A library for PowerNukkitX that adds easier usage on Kotlin with DSL support.

Awesome Lists containing this project

README

        

# kommand-pnx
A library for PowerNukkitX that adds easier usage on Kotlin with DSL support.

[![](https://jitpack.io/v/dev.minjae/kommand-pnx.svg)](https://jitpack.io/#dev.minjae/kommand-pnx)
# Installation
## Gradle (Groovy)
```groovy
repositories {
maven { url 'https://jitpack.io' }
}

dependencies {
implementation 'dev.minjae:kommand-pnx:version'
}
```
## Gradle (Kotlin DSL)
```kotlin
repositories {
maven("https://jitpack.io")
}

dependencies {
implementation("dev.minjae:kommand-pnx:version")
}
```

## Maven
```xml


jitpack.io
https://jitpack.io


dev.minjae
kommand-pnx
version

```
Replace version with commit hash, or tag version.

# Example Usage
```kotlin
override fun onEnable() {
logger.info("Hello World from onEnable()!")
val command = kommand("test", "Test Command with Kommand!") {
commandParameters.clear()
overload("testOverload") {
param("testIntParam", CommandParamType.INT)
param("testPlayerParam", CommandParamType.TARGET)
}
param("testStringParam", CommandParamType.STRING)

onExecute { commandSender, _, mutableEntry, commandLogger ->
val value = mutableEntry.value
if (value.size == 1) {
val paramFirstValue = value[0]
when (paramFirstValue) {
is StringNode -> {
commandLogger.addSuccess("Hello World from onExecute()! ${paramFirstValue.get()}")
.output()
}

else -> throw IllegalArgumentException("Invalid paramFirstValue type: ${paramFirstValue::class.simpleName}")
}
} else {
val firstValue = value[0].get()
val secondValue = value[1].get>()
commandLogger.addSuccess("Hello World from onExecute()! $firstValue, ${secondValue.firstOrNull()?.name ?: ""}")
.output()
}
1
}
}
server.commandMap.register("test", command)
}

```