Resource KInventories - Inventories made simple

Discussion in 'Spigot Plugin Development' started by Redrield, Apr 24, 2017.

  1. Hey everyone.

    Ever since I've started making plugins, I found that the way we were supposed to chain together the creation of inventories with events in order to make a functional GUI very annoying to work with. For this reason, I decided to make an API for developers to work with in order to make this much more pleasing. I've called it KInventories for reasons that will become clear in a moment.

    KInventories works off of nested lambdas in order to put together an inventory. The declaration of an inventory with some items in it and some listeners may look like this:
    Code (Text):
    val inv = inventory("My cool inventory", 18) {
        itemStack(Material.DIAMOND_SWORD) {
            itemMeta {
                displayName = "Super powerful sword"
                lore = listOf("This is a spoopily powerful sword right here")
            addUnsafeEnchantment(Enchantment.DAMAGE_ALL, 1000)
        itemStack(Material.GOLD_CHESTPLATE, amount = 3, slot = 8) {
            itemMeta {
                displayName = "Not as good as the sword, but there are more of them."
        itemStack(Material.GOLD_SWORD) {
            itemMeta {
                displayName = "You could do a lot better than me"
            onClick {
                it.sendMessage("NO TOUCHING")
        onOpen {
             println("Inventory open callback here")
        onClose {
            println("Inventory close callback here")
    Those of you who are very observant may have noticed that snippet is written in Kotlin, and so we come back to the name of this. This framework is meant to be used with Kotlin, though it does have code for Java. Java example here:

    To depend on dis

    add as a repository
    add com.redrield:kinventories:1.0 as a dependency (Shade it)

    In your onEnable, add this
    Code (Text):
    Source is at, issues can go there too, I guess.
    #1 Redrield, Apr 24, 2017
    Last edited: May 1, 2017
    • Like Like x 3
    • Useful Useful x 1
  2. Bump: version 1.1, few feature changes
  3. Bump: Version 1.2, Kotlin users can now mutate the ItemStack being clicked in #onClick. Can also specify a default durability
  4. @Redrield i can't seem to be able to use
    KInventories.register in onenable?