Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/rqbik/bukkt
Kotlin extensions for Bukkit
https://github.com/rqbik/bukkt
bukkit minecraft spigot
Last synced: 5 days ago
JSON representation
Kotlin extensions for Bukkit
- Host: GitHub
- URL: https://github.com/rqbik/bukkt
- Owner: rqbik
- Created: 2020-12-03T14:18:44.000Z (about 4 years ago)
- Default Branch: master
- Last Pushed: 2020-12-25T12:53:14.000Z (about 4 years ago)
- Last Synced: 2024-12-05T08:16:05.511Z (2 months ago)
- Topics: bukkit, minecraft, spigot
- Language: Kotlin
- Homepage:
- Size: 87.9 KB
- Stars: 1
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Buk.kt
Dependency:
```kotlin
repositories {
maven { setUrl("https://jitpack.io/") }
}dependencies {
implementation("com.github.rqbik", "bukkt", "1.0.3")
}
```Example:
```kotlin
class Plugin : JavaPlugin() {
override fun onEnable() {
events { // Automatically registers every event listener that you declare.
listen { // On block break
world.spawn(block.location).apply {
color = DyeColor.RED
}server.broadcastMessage {
"Player $name just broke a block!"
}if (block.type == Material.DIAMOND_BLOCK)
player.equipment?.fill(EquipmentType.DIAMOND) // Fills player's equipment with diamond armorif (block.type == Material.TNT) player.kill()
if (block.type in Tag.WOOL) player.fly = true
// Sometimes IDEA bugs out and can't import operator extensions.
// To fix this, place this import: `import com.github.rqbik.bukkt.extensions.vecloc.contains`
if (block.location in BoundingBox(-100.0..100.0, 0.0..255.0, -100.0..100.0)) {
isCancelled = true
player.sendMessage("You can't break blocks at spawn!")
}player.sendMessage(
"{name}, you just broke {type}".replace(
"{name}" to player.name,
"{type}" to block.type
)
)
}listen {
val player = entity as? Player ?: return@listenplayer.give(Material.DIRT)
player.give(Material.DIAMOND_BLOCK, 2)
player.give(item(Material.POTION, 1, "Poison") {
basePotionData = PotionData(PotionType.POISON)
})player.sendMessage(
"Hey!",
"Your name is ${player.name}"
)
}listen {
// Creates a scoreboard
val scoreboard = scoreboard("&9Information".colorize()) {
// Adds a line
line("Your nickname: ${player.name}")
line("Your exp: ") {
onRender { // This will be invoked when player first sees this line
newText = "Your exp: ${(0..10).random()}"
}
}line("Health: ${player.health}") {
onUpdate { // This will be invoked on each line update
// Update scoreboard line text with new health value
newText = "Health: ${player.health}"
}
}title {
onUpdate {
newTitle = "&9Information: ${player.name}"
}
}
}scoreboard.show(player)
// Update scoreboard every 10 ticks
scheduler.runTaskTimer(plugin, Time(0), Time(10) of TimeType.TICKS) {
scoreboard.updateLines()
}
}listen {
if (!moved) return@listen // Checks if player changed his location// Checks if player is in 10 block radius of world spawnpoint
if (player.location in world.spawnLocation.range(10))
player.sendMessage("&9You &rare near &cspawn!".colorize())
}listen {
if (itemStack.isArmor) {
player.sendMessage("You just dropped armor!")
}
}
}
}
}
```