VitalItem

open class VitalItem : VitalHasInfo

Defines an interactable item within the Vital-Framework.

@VitalItem.Info(
name = "MyItem",
type = Material.STONE
)
public class MyItem extends VitalItem {
@Override
public void onLeftClick(PlayerInteractEvent e) {
// ...
}

@Override
public void onRightClick(PlayerInteractEvent e) {
// ...
}

@Override
public void onCooldown(PlayerInteractEvent e) {
// ...
}

@Override
public void onCooldownExpire(Player player) {
// ...
}

@Override
public void onCooldownTick(Player player) {
// ...
}
}

Constructors

Link copied to clipboard
constructor()

Types

Link copied to clipboard
@Component
@Target(allowedTargets = [AnnotationTarget.CLASS])
annotation class Info(val type: Material, val name: String, val lore: Array<String> = [], val cooldown: Int = 0, val itemFlags: Array<ItemFlag> = [], val amount: Int = 1, val glint: Boolean = false, val unbreakable: Boolean = true)

Defines the info for a VitalItem.

Properties

Link copied to clipboard
Link copied to clipboard

The cooldowns for each player of this item. Once the cooldown for a player expires, the player will be removed from this Map.

Link copied to clipboard

This id is required to identify a single VitalItem during event processing and delegation.

Functions

Link copied to clipboard
open operator override fun equals(other: Any?): Boolean
Link copied to clipboard
open fun <T : Annotation> getInfo(type: Class<T>): T
Link copied to clipboard
fun getItemStack(player: SpigotPlayer): ItemStack

Gets the ItemStack for the given player.

Link copied to clipboard
fun handleInteraction(e: PlayerInteractEvent)

Internal function to handle the given PlayerInteractEvent for this item. This function handles all lifecycle functions of this item and the cooldown logic.

Link copied to clipboard
open fun onCooldown(e: PlayerInteractEvent)

Lifecycle function; called when this item is left- or right-clicked by a player and the player's cooldown is currently active.

Link copied to clipboard
open fun onCooldownExpire(player: SpigotPlayer)

Lifecycle function; called when this item's cooldown expires for a player. This function is also called when a player doesn't have this item equipped.

Link copied to clipboard
open fun onCooldownTick(player: SpigotPlayer)

Lifecycle function; called when the cooldown task ticks the cooldown for this item and a given player. This function is also called when a player doesn't have this item equipped.

Link copied to clipboard
open fun onLeftClick(e: PlayerInteractEvent)

Lifecycle function; called when this item is right-clicked by a player and the player's cooldown is not active.

Link copied to clipboard
open fun onRightClick(e: PlayerInteractEvent)

Lifecycle function; called when this item is left-clicked by a player and the player's cooldown is not active.

Link copied to clipboard
open override fun toString(): String