https://github.com/devsrsouza/kotlinbukkitapi
KotlinBukkitAPI is an API for Bukkit/SpigotAPI using the cool and nifty features Kotlin has to make your life more easier.
https://github.com/devsrsouza/kotlinbukkitapi
bukkit dsl kotlin minecraft spigot
Last synced: 10 months ago
JSON representation
KotlinBukkitAPI is an API for Bukkit/SpigotAPI using the cool and nifty features Kotlin has to make your life more easier.
- Host: GitHub
- URL: https://github.com/devsrsouza/kotlinbukkitapi
- Owner: DevSrSouza
- License: mit
- Created: 2018-03-03T08:25:34.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2023-06-25T13:41:41.000Z (almost 3 years ago)
- Last Synced: 2024-12-19T06:09:18.525Z (over 1 year ago)
- Topics: bukkit, dsl, kotlin, minecraft, spigot
- Language: Kotlin
- Homepage:
- Size: 875 KB
- Stars: 157
- Watchers: 11
- Forks: 20
- Open Issues: 11
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README

## KotlinBukkitAPI

[](https://github.com/DevSrSouza/KotlinBukkitAPI/stargazers)
[](https://github.com/DevSrSouza/KotlinBukkitAPI/issues)
[](https://github.com/DevSrSouza/KotlinBukkitAPI/commit)
[](https://discord.gg/HhucBqk)
[](https://bstats.org/plugin/bukkit/KotlinBukkitAPI/6356)
[](https://choosealicense.com/licenses/mit)
[](http://jenkins.devsrsouza.com.br/job/KotlinBukkitAPI/)
KotlinBukkitAPI is an API for Bukkit/SpigotAPI using the cool and nifty features Kotlin has to make your life more easier.
* Need help? contact me on [Twitter](https://twitter.com/DevSrSouza) or join the [Discord](https://discord.gg/HhucBqk)
## ANNOUNCEMENT
**Developer returns to the project! You can find a lot more information at [Discord](https://discord.gg/HhucBqk), join and chat with me!**
### Contents:
* [Documentation](https://github.com/DevSrSouza/KotlinBukkitAPI/wiki/)
* [Issue reporting](https://github.com/DevSrSouza/KotlinBukkitAPI/issues)
* [Dev builds (download)](http://jenkins.devsrsouza.com.br/job/KotlinBukkitAPI/)
* [Starter project](https://github.com/KotlinMinecraft/KBAPI-StarterProject/)
* [Setup for development](https://github.com/DevSrSouza/KotlinBukkitAPI/wiki/Getting-Started)
* [Example plugins](https://github.com/KotlinMinecraft)
# Samples
## [We have more Samples in the Documentation](https://github.com/DevSrSouza/KotlinBukkitAPI/wiki/)
KotlinBukkitAPI goes beyond this samples, and you can find all of it in the [wiki/documentation](https://github.com/DevSrSouza/KotlinBukkitAPI/wiki/).
Event DSL sample
```kotlin
plugin.events {
event {
player.msg("&3Welcome ${player.name}".translateColor())
}
event {
broadcast("&eThe player &c${player.name} &eleft :(".translateColor())
}
}
```
Simple Command DSL example
```kotlin
plugin.simpleCommand("twitter") {
sender.msg("&eFollow me on Twitter :D &ahttps://twitter.com/DevSrSouza".translateColor())
}
```
Item meta DSL and other stuff
```kotlin
val gem = item(Material.DIAMOND).apply {
amount = 5
meta {
displayName = "&bGem".translateColor()
}
}
val encbook = item(Material.ENCHANTED_BOOK).meta {
displayName = "&4&lThe powerful BOOK".translateColor()
addStoredEnchant(Enchantment.DAMAGE_ALL, 10, true) // putting sharpness 10 to the book
}
```
Another approach:
```
val gem = item(Material.DIAMOND, amount = 5).displayName("&bGem".translateColor())
val encbook = metadataItem(Material.ENCHANTED_BOOK) {
displayName = "&4&lThe powerful BOOK".translateColor()
addStoredEnchant(Enchantment.DAMAGE_ALL, 10, true) // putting sharpness 10 to the book
}
```
Menu creator DSL
```kotlin
val myMenu = menu(+"&cWarps", 3, true) {
val arenaPvP = item(Material.DIAMOND_SWORD) {
addEnchant(Enchantment.DAMAGE_ALL, 5, true)
displayName = "&4Arena PvP".translateColor()
}
slot(2, 4, arenaPvP) { // Line, Slot
onClick {
player.teleport(Location(player.world, 250, 70, -355))
close() // close the menu
}
}
slot(2, 6, item(Material.GOLD).displayName("&6Shop".translateColor())) {
onClick {
player.teleport(Location(player.world, 2399, 70, -1234))
close() // close the menu
}
}
// when the menu renders to a player, will show the Paper item with their name.
slot(3, 9, item(Material.PAPER).displayName("Hello {player}")) {
onRender {
showingItem?.meta {
displayName = displayName.replace("{player}", player.name)
}
}
}
}
// open to player
myMenu.openToPlayer(player)
```
You can find more examples in the [Documentation](https://github.com/DevSrSouza/KotlinBukkitAPI/wiki/)
# Project
## Modules

| Module | Description |
|-------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| Architecture | KotlinPlugin and Lifecycle aware APIs, inspired in Android Lifecycle Components |
| Extensions | Extensions for bunch of Bukkit types like block, player, inventory, text, permissions, etc |
| Utility | Utility types and APIs for Kotlin and Bukkit development, for example, ExpiratioList, OnlinePlayerCollections, Kotlin Duration tick support. |
| Coroutines | Adds Kotlin Coroutines Dispatcher for Bukkit Scheduler API as well as adding Flow APIs and Structured Concurrency (CoroutineScope bounded to Lifecycle of the plugin or Manager class). |
| Exposed | Extensions for SQL framework [Exposed](https://github.com/JetBrains/Exposed/) |
| Serialization | Extensions for [Kotlinx.serialization](https://github.com/Kotlin/kotlinx.serialization) |
| Menu | DSL to create Menus easy and support for Preview in IntelliJ by using the [Plugin](https://github.com/DevSrSouza/KotlinBukkitAPI-Tooling#menu-preview) |
| Command Legacy | DSL to create Commands and Sub Commands with Parameter type safe, auto registering and support for Coroutines |
| Scoreboard Legacy | DSL to create Scoreboard with support for handling updates easily |
## Consider donate

