VirtualInventoryInteractEvent

An event that represents an interaction with a virtual inventory. This event is fired when a player interacts with a virtual inventory, such as clicking on an item or dragging items in the inventory. It contains information about the interaction, such as the type of click, the item being interacted with, and the changes being made to the virtual inventory. This event can be listened to in order to handle interactions with virtual inventories and update them accordingly.

The main purpose of this event is to provide a way to handle interactions with virtual inventories in a consistent way, regardless of the specific implementation of the virtual inventory. By providing information about the interaction and the changes being made to the virtual inventory, this event allows for flexible handling of virtual inventory interactions and can be used to create complex and dynamic GUIs.

Constructors

Link copied to clipboard
constructor(event: VirtualInventoryInteractEvent, virtualInventory: VirtualInventory)
constructor(mcEvent: InventoryDragEvent, gui: Gui)
constructor(mcEvent: InventoryClickEvent, gui: Gui, virtualInventory: VirtualInventory)
constructor(mcEvent: InventoryClickEvent, gui: Gui)

Types

Link copied to clipboard
data class SlotChange(val physicalSlot: Int, val virtualSlot: Int, val oldItem: ItemStack?, val newItem: ItemStack?, val virtualInventory: VirtualInventory)

Represents a change to a specific slot in the virtual inventory as a result of an interaction. This class contains information about the physical slot that was interacted with, the corresponding virtual slot in the virtual inventory, the old item that was in the slot before the interaction, and the new item that will be in the slot after the interaction. It also provides helper properties to determine if the change is an addition, removal, update, or swap of items.

Properties

Link copied to clipboard
val clickType: ClickType

The type of click that was performed in the interaction, such as left-click, right-click, shift-click, etc. This is determined by the underlying Bukkit event and provides information about how the player interacted with the inventory, which can be used to handle the interaction appropriately.

Link copied to clipboard
val gui: Gui

The GUI that fired the event.

Link copied to clipboard
val inventoryAction: InventoryAction

The type of inventory action that was performed in the interaction, such as picking up an item, placing an item, swapping with the cursor, etc. This is determined by the underlying Bukkit event and provides information about what kind of interaction occurred, which can be used to handle the interaction appropriately.

Link copied to clipboard

Indicates whether the interaction should be cancelled. Setting this to true will prevent the default behavior of the underlying Bukkit event, allowing for custom handling of the interaction without interference from the default mechanics. This can be used to implement custom rules or restrictions on how players can interact with the virtual inventory, such as preventing certain types of interactions or enforcing specific behaviors when interacting with certain items or slots.

Link copied to clipboard

Helper property to determine if the click was a left-click, which is the default type of click in inventory interactions. This is determined by checking the ClickType of the interaction and can be used to handle left-click interactions differently from right-clicks or shift-clicks.

Link copied to clipboard

Helper property to determine if the click was a right-click, which can indicate different behavior in inventory interactions (e.g., placing items one at a time). This is determined by checking the ClickType of the interaction and can be used to handle right-click interactions differently from left-clicks.

Link copied to clipboard

Helper property to determine if the click was a shift-click, which is a common modifier in inventory interactions that can indicate different behavior (e.g., moving items between inventories). This is determined by checking the ClickType of the interaction and can be used to handle shift-click interactions differently from regular clicks.

Link copied to clipboard
val mcEvent: InventoryInteractEvent

The underlying Bukkit event that triggered this virtual inventory interaction. This can be either an InventoryClickEvent or an InventoryDragEvent, depending on the type of interaction. This property provides access to the original event for any additional information that may be needed to handle the interaction, such as the player who interacted, the inventory involved, and other details specific to the type of event.

Link copied to clipboard
val newCursor: ItemStack?

The item that will be on the cursor after the interaction occurs. This can be null if the cursor will be empty after the interaction. This property provides information about what item the player will be holding with their cursor after the interaction, which can be used to determine how to handle the interaction and update the virtual inventory accordingly.

Link copied to clipboard
val oldCursor: ItemStack?

The item that was on the cursor before the interaction occurred. This can be null if the cursor was empty. This property provides information about what item the player was holding with their cursor before the interaction, which can be used to determine how to handle the interaction and update the virtual inventory accordingly.

Link copied to clipboard
val player: Player

The player who interacted with the virtual inventory.

Link copied to clipboard

The instance of the ColosseumPlugin that is associated with this event. This is accessed through the GUI that fired the event, as the GUI is created and managed by the ColosseumPlugin. This property provides access to the plugin instance for any additional functionality or information that may be needed to handle the virtual inventory interaction, such as accessing configuration, scheduling tasks, or interacting with other parts of the plugin.

Link copied to clipboard

A list of changes to the slots in the virtual inventory that will occur as a result of the interaction. Each SlotChange in the list represents a change to a specific slot in the virtual inventory, including the physical slot that was interacted with, the corresponding virtual slot, the old item in that slot, and the new item that will be in that slot after the interaction. This list provides a comprehensive overview of how the virtual inventory will be affected by the interaction, allowing for flexible handling and updating of the virtual inventory based on the player's actions.