io.github.parzivalExe.guiApi.components.EventComponent.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of guiapi-mc1.8 Show documentation
Show all versions of guiapi-mc1.8 Show documentation
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 io.github.parzivalExe.guiApi.Gui
import io.github.parzivalExe.guiApi.antlr.interfaces.XMLAttribute
import io.github.parzivalExe.guiApi.events.EventComponentClickedEvent
import org.bukkit.Bukkit
import org.bukkit.Material
import org.bukkit.entity.HumanEntity
import org.bukkit.event.inventory.ClickType
import org.bukkit.event.inventory.InventoryAction
import org.bukkit.inventory.ItemStack
/**
* general
* This is a special component based on the class {@link Component}. If you click this component it will fire the event {@see GuiEventComponentClickedEvent}.
*
* @author Parzival
* @category Component
* @version 2.0
* @since 1.0
* @extends no
* @initialize yes
* @basedOn {@link Component}
*/
class EventComponent(componentMeta: ComponentMeta) : Component(componentMeta) {
@XMLAttribute
var closeGui = true
@Suppress("unused")
@Deprecated("DON'T USE: This Constructor is only used for XML and shouldn't be used in Code itself", ReplaceWith("new EventComponent(ComponentMeta)"))
internal constructor() : this(ComponentMeta("", ItemStack(Material.WOOL)))
override fun componentClicked(whoClicked: HumanEntity, gui: Gui, action: InventoryAction, slot: Int, clickType: ClickType) {
Bukkit.getPluginManager().callEvent(EventComponentClickedEvent(this, whoClicked, gui, action, slot, clickType))
if(closeGui)
gui.closeGui()
}
}