Class GuiItem
java.lang.Object
com.github.stefvanschie.inventoryframework.gui.GuiItem
An item for in an inventory
-
Constructor Summary
ConstructorDescriptionCreates a new gui item based on the item stack and actionGuiItem
(@NotNull ItemStack item, @Nullable Consumer<InventoryClickEvent> action) Creates a new gui item based on the item stack and actionGuiItem
(@NotNull ItemStack item, @Nullable Consumer<InventoryClickEvent> action, @NotNull Plugin plugin) Creates a new gui item based on the item stack and actionCreates a new gui item based on the item stack and action -
Method Summary
Modifier and TypeMethodDescriptionvoid
Sets the internal UUID of this gui item onto the underlying item.void
callAction
(@NotNull InventoryClickEvent event) Calls the handler of theInventoryClickEvent
if such a handler was specified in the constructor.@NotNull GuiItem
copy()
Makes a copy of this gui item and returns it.@NotNull ItemStack
getItem()
Returns the item@NotNull NamespacedKey
getKey()
Gets the namespaced key used for this item.Returns the list of properties@NotNull UUID
getUUID()
boolean
Returns whether or not this item is visiblevoid
setAction
(@NotNull Consumer<InventoryClickEvent> action) Sets the action to be executed when a human entity clicks on this item.void
Overwrites the current item with the provided item.void
setProperties
(@NotNull List<Object> properties) Sets the list of properties for this gui itemvoid
setVisible
(boolean visible) Sets the visibility of this item to the new visibility
-
Constructor Details
-
GuiItem
public GuiItem(@NotNull @NotNull ItemStack item, @Nullable @Nullable Consumer<InventoryClickEvent> action, @NotNull @NotNull Plugin plugin) Creates a new gui item based on the item stack and action- Parameters:
item
- the item stackaction
- the action called whenever an interaction with this item happensplugin
- the owning plugin of this item- Since:
- 0.10.8
- See Also:
-
GuiItem
Creates a new gui item based on the item stack and action- Parameters:
item
- the item stackplugin
- the owning plugin of this item- Since:
- 0.10.8
- See Also:
-
GuiItem
public GuiItem(@NotNull @NotNull ItemStack item, @Nullable @Nullable Consumer<InventoryClickEvent> action) Creates a new gui item based on the item stack and action- Parameters:
item
- the item stackaction
- the action called whenever an interaction with this item happens
-
GuiItem
Creates a new gui item based on the item stack and action- Parameters:
item
- the item stack
-
-
Method Details
-
copy
Makes a copy of this gui item and returns it. This makes a deep copy of the gui item. This entails that the underlying item will be copied as per theirItemStack.clone()
and miscellaneous data will be copied in such a way that they are identical. The returned gui item will never be reference equal to the current gui item.- Returns:
- a copy of the gui item
- Since:
- 0.6.2
-
callAction
Calls the handler of theInventoryClickEvent
if such a handler was specified in the constructor. Catches and logs all exceptions the handler might throw.- Parameters:
event
- the event to handle- Since:
- 0.6.0
-
applyUUID
public void applyUUID()Sets the internal UUID of this gui item onto the underlying item. Previously set UUID will be overwritten by the current UUID. If the underlying item does not have an item meta, this method will silently do nothing.- Since:
- 0.9.3
-
setItem
Overwrites the current item with the provided item.- Parameters:
item
- the item to set- Since:
- 0.10.8
-
setAction
Sets the action to be executed when a human entity clicks on this item.- Parameters:
action
- the action of this item- Since:
- 0.7.1
-
getProperties
Returns the list of properties- Returns:
- the list of properties that belong to this gui item
- Since:
- 0.7.2
-
setProperties
Sets the list of properties for this gui item- Parameters:
properties
- list of new properties- Since:
- 0.7.2
-
getItem
Returns the item- Returns:
- the item that belongs to this gui item
-
getKey
Gets the namespaced key used for this item.- Returns:
- the namespaced key
- Since:
- 0.10.8
-
getUUID
- Returns:
- the
UUID
of this item - Since:
- 0.5.9
-
isVisible
public boolean isVisible()Returns whether or not this item is visible- Returns:
- true if this item is visible, false otherwise
-
setVisible
public void setVisible(boolean visible) Sets the visibility of this item to the new visibility- Parameters:
visible
- the new visibility
-