AutoCycleItemProvider

class AutoCycleItemProvider(items: List<ItemStack>, val plugin: ColosseumPlugin, cycleInterval: Long = 1) : AbstractItemProvider

An ItemProvider that automatically cycles through a list of items at a specified interval. This is useful for creating dynamic GUI elements that change over time without user interaction.

Parameters

items

The list of items to cycle through. The provider will display one item at a time, cycling through the list in order.

plugin

The instance of the ColosseumPlugin, used to schedule the cycling task

cycleInterval

The interval in ticks at which to cycle to the next item. Defaults to 1 tick (20 cycles per second).

Constructors

Link copied to clipboard
constructor(items: List<ItemStack>, plugin: ColosseumPlugin, cycleInterval: Long = 1)

Properties

Link copied to clipboard

Functions

Link copied to clipboard
open override fun destroy()

Cleans up any resources or references when this item provider is removed from the GUI. Subclasses can override this method to perform any necessary cleanup, such as canceling tasks or clearing references.

Link copied to clipboard
open override fun getItem(): ItemStack?

Returns the ItemStack to be displayed for this item provider. This method must be implemented by subclasses to provide the actual item to display.

Link copied to clipboard
open override fun onClick(clickEvent: InventoryClickEvent)

Handles click events for this item provider. This method must be implemented by subclasses to define the behavior when the item is clicked in the GUI.

Link copied to clipboard
fun refresh()

Refreshes the item in the GUI. This method can be called by subclasses to update the displayed item after changes. It checks if the GUI reference is initialized and if the inventory slot is valid before attempting to refresh.

Link copied to clipboard
fun setGuiData(gui: Gui, slot: Int)

Sets the GUI reference and inventory slot for this item provider. This should be called by the GUI when adding this item provider to it.