Class StaticPane
java.lang.Object
com.github.stefvanschie.inventoryframework.pane.Pane
com.github.stefvanschie.inventoryframework.pane.StaticPane
A pane for static items and stuff. All items will have to be specified a slot, or will be added in the next position.
This pane allows you to specify the positions of the items either in the form of an x and y coordinate pair or as an index, in which case the indexing starts from the top left and continues to the right and bottom, with the horizontal axis taking priority. There are nuances at play with regard to mixing these two types of positioning systems within the same pane. It's recommended to only use one of these systems per pane and to not mix them.
-
Nested Class Summary
Nested classes/interfaces inherited from class Pane
Pane.Priority -
Field Summary
-
Constructor Summary
ConstructorsConstructorDescriptionStaticPane(int length, int height) Creates a new static pane.StaticPane(int length, int height, @NotNull Pane.Priority priority) Creates a new static pane. -
Method Summary
Modifier and TypeMethodDescriptionvoidAdds a gui item at the specific spot in the pane.voidAdds a gui item at the specific spot in the pane.voidclear()Clears the entire pane of any items/panes.booleanclick(@NotNull Gui gui, @NotNull GuiComponent guiComponent, @NotNull InventoryClickEvent event, @NotNull Slot slot) Called whenever there is being clicked on this pane@NotNull StaticPanecopy()Makes a copy of this pane and returns it.@NotNull GuiItemContainerdisplay()Returns aGuiItemContainerwith all the items that should be displayed of this pane.voidFills all empty space in the pane with the givenitemStackvoidfillWith(@NotNull ItemStack itemStack, @Nullable Consumer<? super InventoryClickEvent> action) Fills all empty space in the pane with the givenitemStackand adds the given actionvoidfillWith(@NotNull ItemStack itemStack, @Nullable Consumer<? super InventoryClickEvent> action, @NotNull Plugin plugin) Fills all empty space in the pane with the givenitemStackand adds the given actionvoidflipHorizontally(boolean flipHorizontally) Sets whether this pane should flip its items horizontallyvoidflipVertically(boolean flipVertically) Sets whether this pane should flip its items vertically@Nullable GuiItemGets the item located at the provided slot.@NotNull Collection<GuiItem> getItems()Gets all the items in this pane and all underlying panes.@NotNull Collection<Pane> getPanes()Gets all the panes in this panes, including any child panes from other panes.intGets the rotation specified to this pane.Gets all items by their corresponding slots.booleanGets whether this pane's items are flipped horizontallybooleanGets whether this pane's items are flipped verticallystatic @NotNull StaticPaneLoads an outline pane from a given elementvoidremoveItem(int x, int y) Removes the specified item from the pane.voidremoveItem(@NotNull GuiItem item) Removes the specified item from the panevoidremoveItem(@NotNull Slot slot) Removes the specified item from the pane.voidsetRotation(int rotation) Sets the rotation of this pane.Methods inherited from class Pane
callOnClick, createBorder, findMatchingItem, getHeight, getLength, getPriority, getUUID, isVisible, load, matchesItem, setHeight, setLength, setOnClick, setPriority, setVisible
-
Constructor Details
-
StaticPane
Creates a new static pane.- Parameters:
length- the length of the paneheight- the height of the panepriority- the priority of the pane- Since:
- 0.12.0
-
StaticPane
public StaticPane(int length, int height) Creates a new static pane.- Parameters:
length- the length of the paneheight- the height of the pane- Since:
- 0.12.0
-
-
Method Details
-
display
Description copied from class:PaneReturns aGuiItemContainerwith all the items that should be displayed of this pane. -
addItem
Adds a gui item at the specific spot in the pane. If the specified slot is already in use, the previous item will be overwritten by the new item. This is regardless of the way the slot is specified.- Parameters:
item- the item to setslot- the position of the item- Since:
- 0.10.8
-
addItem
Adds a gui item at the specific spot in the pane. If there is another item specified in terms of x and y coordinates that are equal to the coordinates of this item, the old item will be overwritten by this item.- Parameters:
item- the item to setx- the x coordinate of the position of the itemy- the y coordinate of the position of the item
-
removeItem
Removes the specified item from the pane- Parameters:
item- the item to remove- Since:
- 0.5.8
-
removeItem
public void removeItem(int x, int y) Removes the specified item from the pane. This will remove an item regardless of how the slot was specified. If there is no item at the specified coordinates, this method will do nothing.- Parameters:
x- the x coordinate of the item to removey- the y coordinate of the item to remove- Since:
- 0.10.0
- See Also:
-
removeItem
Removes the specified item from the pane. This will remove an item regardless of how the slot was specified. If there is no item at the specified coordinates, this method will do nothing.- Parameters:
slot- the slot of the item to remove- Since:
- 0.10.8
-
click
public boolean click(@NotNull @NotNull Gui gui, @NotNull @NotNull GuiComponent guiComponent, @NotNull @NotNull InventoryClickEvent event, @NotNull @NotNull Slot slot) Description copied from class:PaneCalled whenever there is being clicked on this pane -
copy
Description copied from class:PaneMakes 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. -
setRotation
public void setRotation(int rotation) Description copied from interface:RotatableSets the rotation of this pane. The rotation is in degrees and can only be in increments of 90. Anything higher than 360, will be lowered to a value in between [0, 360) while maintaining the same rotational value. E.g. 450 degrees becomes 90 degrees, 1080 degrees becomes 0, etc. This method fails for any pane that has a length and height which are unequal.- Specified by:
setRotationin interfaceRotatable- Parameters:
rotation- the rotation of this pane, must be divisible by 90.
-
fillWith
public void fillWith(@NotNull @NotNull ItemStack itemStack, @Nullable @Nullable Consumer<? super InventoryClickEvent> action, @NotNull @NotNull Plugin plugin) Fills all empty space in the pane with the givenitemStackand adds the given action- Parameters:
itemStack- TheItemStackto fill the empty space withaction- The action called whenever an interaction with the item happensplugin- the plugin that will be the owner of the created items- Since:
- 0.10.8
- See Also:
-
fillWith
public void fillWith(@NotNull @NotNull ItemStack itemStack, @Nullable @Nullable Consumer<? super InventoryClickEvent> action) Fills all empty space in the pane with the givenitemStackand adds the given action- Parameters:
itemStack- TheItemStackto fill the empty space withaction- The action called whenever an interaction with the item happens- Since:
- 0.5.9
-
fillWith
-
getItem
Gets the item located at the provided slot. If the provided slot is empty, this will return null. The slots are checked based on their position without regard for their underlying definition. For example, if an item was added with its slot specified as an x,y coordinate pair, but this method is invoked with a slot specified as an index, this item may still be returned if the x,y coordinate pair and slot are at the same position, given the current dimensions of the pane. If multiple items match the position indicated by the provided slot, any of those items may be the result of this invocation.- Parameters:
slot- the slot of the item- Returns:
- the item at this position, or null if there is no such item
- Since:
- 0.11.4
-
getItems
Description copied from class:PaneGets 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.) -
getSlottedItems
@NotNull @Contract(pure=true) public @NotNull Map<@NotNull Slot, @NotNull GuiItem> getSlottedItems()Gets all items by their corresponding slots. The slots correspond to the type they were added with. For example, if the slot was specified as an x,y coordinate pair, the slot will also be specified as such a pair. The returned map is unmodifiable.- Returns:
- a map of all items by their slot
- Since:
- 0.11.4
-
clear
-
getPanes
Description copied from class:PaneGets 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.) -
flipHorizontally
public void flipHorizontally(boolean flipHorizontally) Description copied from interface:FlippableSets whether this pane should flip its items horizontally- Specified by:
flipHorizontallyin interfaceFlippable- Parameters:
flipHorizontally- whether the pane should flip items horizontally
-
flipVertically
public void flipVertically(boolean flipVertically) Description copied from interface:FlippableSets whether this pane should flip its items vertically- Specified by:
flipVerticallyin interfaceFlippable- Parameters:
flipVertically- whether the pane should flip items vertically
-
getRotation
@Contract(pure=true) public int getRotation()Description copied from interface:RotatableGets the rotation specified to this pane. If no rotation has been set, or if this pane is not capable of having a rotation, 0 is returned.- Specified by:
getRotationin interfaceRotatable- Returns:
- the rotation for this pane
-
isFlippedHorizontally
@Contract(pure=true) public boolean isFlippedHorizontally()Description copied from interface:FlippableGets whether this pane's items are flipped horizontally- Specified by:
isFlippedHorizontallyin interfaceFlippable- Returns:
- true if the items are flipped horizontally, false otherwise
-
isFlippedVertically
@Contract(pure=true) public boolean isFlippedVertically()Description copied from interface:FlippableGets whether this pane's items are flipped vertically- Specified by:
isFlippedVerticallyin interfaceFlippable- Returns:
- true if the items are flipped vertically, false otherwise
-
load
@NotNull public static @NotNull StaticPane load(@NotNull @NotNull Object instance, @NotNull @NotNull Element element, @NotNull @NotNull Plugin plugin) Loads an outline pane from a given element- Parameters:
instance- the instance classelement- the elementplugin- the plugin that will be the owner of the udnerlying items- Returns:
- the outline pane
- Since:
- 0.10.8
-