Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
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.
- Host: GitHub
- URL: https://github.com/alvin0319/kommand-pnx
- Owner: alvin0319
- Created: 2023-06-14T14:29:38.000Z (over 1 year ago)
- Default Branch: master
- Last Pushed: 2023-07-14T16:02:49.000Z (over 1 year ago)
- Last Synced: 2024-11-01T13:42:01.838Z (2 months ago)
- Language: Kotlin
- Size: 76.2 KB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
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)
}```