Class Pane
java.lang.Object
com.github.stefvanschie.inventoryframework.pane.Pane
- Direct Known Subclasses:
CycleButton, Label, MasonryPane, OutlinePane, PaginatedPane, PagingButtons, PatternPane, StaticPane, ToggleButton, VariableBar
The base class for all panes.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enumAn enum representing the rendering priorities for the panes. -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected intLength is horizontal, height is verticalprotected intLength is horizontal, height is verticalprotected @Nullable Consumer<? super InventoryClickEvent> The consumer that will be called once a players clicks in this paneprotected UUIDA unique identifier for panes to locate them by -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedPane(int length, int height) Constructs a new default pane, with no positionprotectedPane(int length, int height, @NotNull Pane.Priority priority) Constructs a new default pane -
Method Summary
Modifier and TypeMethodDescriptionprotected voidcallOnClick(@NotNull InventoryClickEvent event) Calls the consumer (if it's not null) that was specified usingsetOnClick(Consumer), so the consumer that should be called whenever this pane is clicked in.abstract voidclear()Clears the entire pane of any items/panes.abstract booleanclick(@NotNull Gui gui, @NotNull GuiComponent guiComponent, @NotNull InventoryClickEvent event, @NotNull Slot slot) Called whenever there is being clicked on this pane@NotNull Panecopy()Makes a copy of this pane and returns it.static @NotNull PanecreateBorder(int length, int height, @NotNull GuiItem item) Creates a pane which displays as a border around the outside of the pane consisting of the provided item.abstract @NotNull GuiItemContainerdisplay()Returns aGuiItemContainerwith all the items that should be displayed of this pane.protected static <T extends GuiItem>
TfindMatchingItem(@NotNull Collection<T> items, @NotNull ItemStack item) intReturns the height of this paneabstract @NotNull Collection<GuiItem> getItems()Gets all the items in this pane and all underlying panes.intReturns the length of this paneabstract @NotNull Collection<Pane> getPanes()Gets all the panes in this panes, including any child panes from other panes.@NotNull Pane.PriorityReturns the priority of the pane@NotNull UUIDgetUUID()Gets theUUIDassociated with this pane.booleanReturns the pane's visibility statestatic voidprotected static booleanmatchesItem(@NotNull GuiItem guiItem, @NotNull ItemStack item) voidsetHeight(int height) Set the height of this panevoidsetLength(int length) Set the length of this panevoidsetOnClick(@Nullable Consumer<? super InventoryClickEvent> onClick) Set the consumer that should be called whenever this pane is clicked in.voidsetPriority(@NotNull Pane.Priority priority) Sets the priority of this panevoidsetVisible(boolean visible) Sets whether this pane is visible or not
-
Field Details
-
length
protected int lengthLength is horizontal, height is vertical -
height
protected int heightLength is horizontal, height is vertical -
onClick
The consumer that will be called once a players clicks in this pane -
uuid
A unique identifier for panes to locate them by
-
-
Constructor Details
-
Pane
Constructs a new default pane- Parameters:
length- the length of the paneheight- the height of the panepriority- the priority of the pane- Since:
- 0.12.0
-
Pane
protected Pane(int length, int height) Constructs a new default pane, with no position- Parameters:
length- the length of the paneheight- the height of the pane
-
-
Method Details
-
copy
Makes a copy of this pane and returns it. This makes a deep copy of the pane. This entails that the underlying panes and/or items will be copied as well. The returned pane will never be reference equal to the current pane.- Returns:
- a copy of this pane
- Since:
- 0.6.2
-
setLength
public void setLength(int length) Set the length of this pane- Parameters:
length- the new length
-
setHeight
public void setHeight(int height) Set the height of this pane- Parameters:
height- the new height
-
getLength
@Contract(pure=true) public int getLength()Returns the length of this pane- Returns:
- the length
-
getHeight
@Contract(pure=true) public int getHeight()Returns the height of this pane- Returns:
- the height
-
getUUID
-
display
Returns aGuiItemContainerwith all the items that should be displayed of this pane.- Returns:
- a container containing all the items to be displayed
- Since:
- 0.12.0
-
isVisible
@Contract(pure=true) public boolean isVisible()Returns the pane's visibility state- Returns:
- the pane's visibility
-
setVisible
public void setVisible(boolean visible) Sets whether this pane is visible or not- Parameters:
visible- the pane's visibility
-
click
public abstract boolean click(@NotNull @NotNull Gui gui, @NotNull @NotNull GuiComponent guiComponent, @NotNull @NotNull InventoryClickEvent event, @NotNull @NotNull Slot slot) Called whenever there is being clicked on this pane- Parameters:
gui- the gui in which was clickedguiComponent- the gui component in which this pane residesevent- the event that occurred while clicking on this itemslot- the slot that was clicked in- Returns:
- whether the item was found or not
-
setPriority
Sets the priority of this pane- Parameters:
priority- the priority
-
load
-
matchesItem
@Contract(pure=true) protected static boolean matchesItem(@NotNull @NotNull GuiItem guiItem, @NotNull @NotNull ItemStack item) Checks whether aGuiItemis the same item as the givenItemStack. The item will be compared using internal data. When the item does not have this data, this method will return false. If the item does have such data, but its value does not match, false is also returned. This method will not mutate any of the provided arguments. -
findMatchingItem
@Nullable @Contract(pure=true) protected static <T extends GuiItem> T findMatchingItem(@NotNull @NotNull Collection<T> items, @NotNull @NotNull ItemStack item) Finds a type ofGuiItemfrom the provided collection of items based on the providedItemStack. The items will be compared using internal data. When the item does not have this data, this method will return null. If the item does have such data, but its value cannot be found in the provided list, null is also returned. This method will not mutate any of the provided arguments, nor any of the contents inside of the arguments. The provided collection may be unmodifiable if preferred. This method will always return a type ofGuiItemthat is in the provided collection - when the returned result is not null - such that an element E inside the provided collection reference equals the returned type ofGuiItem.- Type Parameters:
T- a type of GuiItem, which will be used in the provided collection and as return type- Parameters:
items- a collection of items in which will be searcheditem- the item for which anGuiItemshould be found- Returns:
- the found type of
GuiItemor null if none was found - Since:
- 0.5.14
-
getPriority
Returns the priority of the pane- Returns:
- the priority
-
getItems
Gets all the items in this pane and all underlying panes. The returned collection is not guaranteed to be mutable or to be a view of the underlying data. (So changes to the gui are not guaranteed to be visible in the returned value.)- Returns:
- all items
-
getPanes
Gets all the panes in this panes, including any child panes from other panes. The returned collection is not guaranteed to be mutable or to be a view of the underlying data. (So changes to the gui are not guaranteed to be visible in the returned value.)- Returns:
- all panes
-
clear
public abstract void clear()Clears the entire pane of any items/panes. Underlying panes will not be cleared.- Since:
- 0.3.2
-
setOnClick
Set the consumer that should be called whenever this pane is clicked in.- Parameters:
onClick- the consumer that gets called- Since:
- 0.4.0
-
callOnClick
Calls the consumer (if it's not null) that was specified usingsetOnClick(Consumer), so the consumer that should be called whenever this pane is clicked in.- Parameters:
event- the event to handle- Since:
- 0.6.0
-
createBorder
@NotNull @Contract(pure=true) public static @NotNull Pane createBorder(int length, int height, @NotNull @NotNull GuiItem item) Creates a pane which displays as a border around the outside of the pane consisting of the provided item. The slot, length and height parameters are used for the respective properties of the pane. If either the length or height is negative anIllegalArgumentExceptionwill be thrown.- Parameters:
length- the length of the paneheight- the height of the paneitem- the item of which the border is made- Returns:
- the created pane which displays a border
- Throws:
IllegalArgumentException- if length or height is negative- Since:
- 0.12.0
-