Class Pane
java.lang.Object
com.github.stefvanschie.inventoryframework.pane.Pane
- Direct Known Subclasses:
CycleButton
,MasonryPane
,OutlinePane
,PaginatedPane
,PagingButtons
,PatternPane
,StaticPane
,ToggleButton
,VariableBar
The base class for all panes.
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic enum
An enum representing the rendering priorities for the panes. -
Field Summary
Modifier and TypeFieldDescriptionprotected int
Length is horizontal, height is verticalprotected int
Length is horizontal, height is verticalprotected @Nullable Consumer
<InventoryClickEvent> The consumer that will be called once a players clicks in this paneprotected @NotNull Slot
The position of this pane, which is (0,0) by defaultprotected UUID
A unique identifier for panes to locate them byprotected int
Deprecated.protected int
Deprecated. -
Constructor Summary
ModifierConstructorDescriptionprotected
Pane
(int length, int height) Constructs a new default pane, with no positionprotected
Pane
(int x, int y, int length, int height) Constructs a new default paneprotected
Pane
(int x, int y, int length, int height, @NotNull Pane.Priority priority) Constructs a new default paneprotected
Pane
(@NotNull Slot slot, int length, int height, @NotNull Pane.Priority priority) Constructs a new default paneprotected
Constructs a new default pane -
Method Summary
Modifier and TypeMethodDescriptionprotected void
callOnClick
(@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 void
clear()
Clears the entire pane of any items/panes.abstract boolean
click
(@NotNull Gui gui, @NotNull InventoryComponent inventoryComponent, @NotNull InventoryClickEvent event, int slot, int paneOffsetX, int paneOffsetY, int maxLength, int maxHeight) Called whenever there is being clicked on this pane@NotNull Pane
copy()
Makes a copy of this pane and returns it.static @NotNull Pane
createBorder
(int x, int y, 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.static @NotNull Pane
createBorder
(Slot slot, 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 void
display
(@NotNull InventoryComponent inventoryComponent, int paneOffsetX, int paneOffsetY, int maxLength, int maxHeight) Has to set all the items in the right spot inside the inventoryprotected static <T extends GuiItem>
TfindMatchingItem
(@NotNull Collection<T> items, @NotNull ItemStack item) int
Returns the height of this paneabstract @NotNull Collection
<GuiItem> getItems()
Gets all the items in this pane and all underlying panes.int
Returns 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.Priority
Returns the priority of the pane@NotNull Slot
getSlot()
Gets the slot of the position of this pane@NotNull UUID
getUUID()
Gets theUUID
associated with this pane.int
getX()
Deprecated.int
getY()
Deprecated.when the slot was specified as an indexed position, this may return the wrong value;getSlot()
should be used insteadboolean
Returns the pane's visibility statestatic void
static @NotNull GuiItem
Loads an item from an instance and an elementstatic @NotNull GuiItem
Loads an item from an instance and an elementprotected static boolean
matchesItem
(@NotNull GuiItem guiItem, @NotNull ItemStack item) static void
registerProperty
(@NotNull String attributeName, @NotNull Function<String, Object> function) Registers a property that can be used inside an XML file to add additional new properties.void
setHeight
(int height) Set the height of this panevoid
setLength
(int length) Set the length of this panevoid
setOnClick
(@Nullable Consumer<InventoryClickEvent> onClick) Set the consumer that should be called whenever this pane is clicked in.void
setPriority
(@NotNull Pane.Priority priority) Sets the priority of this panevoid
Sets the slot of this pane.void
setVisible
(boolean visible) Sets whether this pane is visible or notvoid
setX
(int x) Set the x coordinate of this panevoid
setY
(int y) Set the y coordinate of this pane
-
Field Details
-
x
Deprecated.The starting position of this pane, which is 0 by default -
y
Deprecated.The starting position of this pane, which is 0 by default -
slot
The position of this pane, which is (0,0) by default -
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
protected Pane(@NotNull @NotNull Slot slot, int length, int height, @NotNull @NotNull Pane.Priority priority) Constructs a new default pane- Parameters:
slot
- the slot of the panelength
- the length of the paneheight
- the height of the panepriority
- the priority of the pane- Since:
- 0.10.8
-
Pane
Constructs a new default pane- Parameters:
x
- the upper left x coordinate of the paney
- the upper left y coordinate of the panelength
- the length of the paneheight
- the height of the panepriority
- the priority of the pane
-
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
-
Pane
Constructs a new default pane- Parameters:
slot
- the slot of the panelength
- the length of the paneheight
- the height of the pane
-
Pane
protected Pane(int x, int y, int length, int height) Constructs a new default pane- Parameters:
x
- the upper left x coordinate of the paney
- the upper left y coordinate of the panelength
- 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
-
setSlot
Sets the slot of this pane.- Parameters:
slot
- the slot- Since:
- 0.10.8
-
setX
public void setX(int x) Set the x coordinate of this pane- Parameters:
x
- the new x coordinate
-
setY
public void setY(int y) Set the y coordinate of this pane- Parameters:
y
- the new y coordinate
-
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
Gets theUUID
associated with this pane.- Returns:
- the uuid
- Since:
- 0.7.1
-
getSlot
Gets the slot of the position of this pane- Returns:
- the slot
- Since:
- 0.10.8
-
getX
Deprecated.when the slot was specified as an indexed position, this may return the wrong value;getSlot()
should be used insteadGets the x coordinate of this pane- Returns:
- the x coordinate
-
getY
Deprecated.when the slot was specified as an indexed position, this may return the wrong value;getSlot()
should be used insteadGets the y coordinate of this pane- Returns:
- the y coordinate
-
display
public abstract void display(@NotNull @NotNull InventoryComponent inventoryComponent, int paneOffsetX, int paneOffsetY, int maxLength, int maxHeight) Has to set all the items in the right spot inside the inventory- Parameters:
inventoryComponent
- the inventory component in which the items should be displayedpaneOffsetX
- the pane's offset on the x axispaneOffsetY
- the pane's offset on the y axismaxLength
- the maximum length of the panemaxHeight
- the maximum height of the pane
-
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 InventoryComponent inventoryComponent, @NotNull @NotNull InventoryClickEvent event, int slot, int paneOffsetX, int paneOffsetY, int maxLength, int maxHeight) Called whenever there is being clicked on this pane- Parameters:
gui
- the gui in which was clickedinventoryComponent
- the inventory component in which this pane residesevent
- the event that occurred while clicking on this itemslot
- the slot that was clicked inpaneOffsetX
- the pane's offset on the x axispaneOffsetY
- the pane's offset on the y axismaxLength
- the maximum length of the panemaxHeight
- the maximum height of the pane- Returns:
- whether the item was found or not
-
setPriority
Sets the priority of this pane- Parameters:
priority
- the priority
-
loadItem
@NotNull @Contract(pure=true) public static @NotNull GuiItem loadItem(@NotNull @NotNull Object instance, @NotNull @NotNull Element element, @NotNull @NotNull Plugin plugin) Loads an item from an instance and an element- Parameters:
instance
- the instanceelement
- the elementplugin
- the plugin that will be the owner of the created item- Returns:
- the gui item
- Since:
- 0.10.8
- See Also:
-
loadItem
@NotNull @Contract(pure=true) public static @NotNull GuiItem loadItem(@NotNull @NotNull Object instance, @NotNull @NotNull Element element) Loads an item from an instance and an element- Parameters:
instance
- the instanceelement
- the element- Returns:
- the gui item
-
load
-
matchesItem
@Contract(pure=true) protected static boolean matchesItem(@NotNull @NotNull GuiItem guiItem, @NotNull @NotNull ItemStack item) Checks whether aGuiItem
is 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 ofGuiItem
from 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 ofGuiItem
that 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 anGuiItem
should be found- Returns:
- the found type of
GuiItem
or 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(Slot slot, 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 anIllegalArgumentException
will be thrown.- Parameters:
slot
- the slot of the panelength
- 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.10.8
-
createBorder
@NotNull @Contract(pure=true) public static @NotNull Pane createBorder(int x, int y, 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 x, y, length and height parameters are used for the respective properties of the pane. If either the length or height is negative anIllegalArgumentException
will be thrown.- Parameters:
x
- the x coordinate of the paney
- the y coordinate of the panelength
- 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.10.7
-
registerProperty
public static void registerProperty(@NotNull @NotNull String attributeName, @NotNull @NotNull Function<String, Object> function) Registers a property that can be used inside an XML file to add additional new properties. The use ofGui.registerProperty(String, Function)
is preferred over this method.- Parameters:
attributeName
- the name of the property. This is the same name you'll be using to specify the property type in the XML file.function
- how the property should be processed. This converts the raw text input from the XML node value into the correct object type.- Throws:
IllegalArgumentException
- when a property with this name is already registered.
-
getSlot()
should be used instead