All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.github.parzivalExe.guiApi.components.ComponentMeta.kt Maven / Gradle / Ivy

Go to download

With GuiAPI you can create Guis for your Bukkit/Spigot-Plugin in seconds while at the same time saving many lines of code

The newest version!
package io.github.parzivalExe.guiApi.components

import org.bukkit.inventory.ItemStack

@Suppress("unused")
class ComponentMeta(var title: String, private var look: ItemStack) {

    var description = arrayListOf()
    var savedObjects = hashMapOf()

    constructor(name: String, look: ItemStack, description: ArrayList) : this(name, look) {
        this.description = description
    }

    //region simple methods

    fun addDescriptionLine(descriptionLine: String) {
        description.add(descriptionLine)
    }

    fun getDescriptionAsString(): String {
        var string = ""
        description.forEach { line -> string += line + "\n" }
        string.removeSuffix("\n")
        return string
    }

    //endregion


    fun setLook(look: ItemStack) {
        this.look = look
    }

    internal fun buildItem(): ItemStack {
        val itemMeta = look.itemMeta
        itemMeta.apply {
            displayName = title
            lore = description
        }
        look.itemMeta = itemMeta
        return look
    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy