Giter Site home page Giter Site logo

pedromdsn / kotlinbukkitapi Goto Github PK

View Code? Open in Web Editor NEW

This project forked from devsrsouza/kotlinbukkitapi

5.0 0.0 0.0 779 KB

KotlinBukkitAPI is an API for Bukkit/SpigotAPI using the cool and nifty features Kotlin has to make your life more easier.

License: MIT License

Kotlin 100.00%

kotlinbukkitapi's Introduction

KotlinBukkitAPI

KotlinBukkitAPI

Kotlin version GitHub stars Github Issues GitHub last commit Discord Minecraft Server Running with KotlinBukkitAPI MIT License Build Status

KotlinBukkitAPI is an API for Bukkit/SpigotAPI using the cool and nifty features Kotlin has to make your life more easier.

Contents:

Samples

KotlinBukkitAPI goes beyond this samples, and you can find all of it in the wiki/documentation.

Event DSL sample

plugin.events {
  event<PlayerJoinEvent> {
    player.msg("&3Welcome ${player.name}".translateColor()) 
  }
  
  event<PlayerQuitEvent> {
    broadcast("&eThe player &c${player.name} &eleft :(".translateColor())
  }
}

Simple Command DSL example

plugin.simpleCommand("twitter") {
  sender.msg("&eFollow me on Twitter :D &ahttps://twitter.com/DevSrSouza".translateColor())
}

Item meta DSL and other stuff

val gem = item(Material.DIAMOND).apply {
  amount = 5
  meta<ItemMeta> {
    displayName = "&bGem".translateColor()
  }
}
val encbook = item(Material.ENCHANTED_BOOK).meta<EnchantmentStorageMeta> {
  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<EnchantmentStorageMeta>(Material.ENCHANTED_BOOK) {
  displayName = "&4&lThe powerful BOOK".translateColor()
    addStoredEnchant(Enchantment.DAMAGE_ALL, 10, true) // putting sharpness 10 to the book
}

Menu creator DSL

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<ItemMeta> {
         displayName = displayName.replace("{player}", player.name)
      } 
    }
  }
}

// open to player
myMenu.openToPlayer(player)

You can find more examples in the Documentation

Project

Dependencies

Name Version
Spigot API 1.8.8+

Dependencies Embed

If you shade your plugin or use PDM, this dependencies should not be loaded be your plugin, you should let the KotlinBukkitAPI provide it at runtime to prevent conflicts.

More about how to setup a project with KotlinBukkitAPI here.

Name Version
Kotlin STD + JDK8 1.4.10
Kotlin Reflect 1.4.10
Kotlinx-coroutines 1.3.9
Skedule 1.2.6
Kotlinx.serialization 1.4.0-RC
KAML 0.19.0
Exposed 0.25.1
HikariCP 3.3.1

Modules

Module Description
Core The heart of the project containing the important API and extensions
Plugins Extensions for others plugins like Vault, PlaceholderAPI and others
Exposed Extensions for SQL framework Exposed
Serialization Extensions for Kotlinx.serialization

Consider donate

Buy Me A Coffee




logo

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.