java.lang.Object
com.github.stefvanschie.inventoryframework.pane.Pane
com.github.stefvanschie.inventoryframework.pane.StaticPane
All Implemented Interfaces:
Flippable, Rotatable

public class StaticPane extends Pane implements Flippable, Rotatable
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.

  • Constructor Details

    • StaticPane

      public StaticPane(Slot slot, int length, int height, @NotNull @NotNull Pane.Priority priority)
      Creates a new static pane.
      Parameters:
      slot - the slot of the pane
      length - the length of the pane
      height - the height of the pane
      priority - the priority of the pane
      Since:
      0.10.8
    • StaticPane

      public StaticPane(int x, int y, int length, int height, @NotNull @NotNull Pane.Priority priority)
    • StaticPane

      public StaticPane(Slot slot, int length, int height)
      Creates a new static pane.
      Parameters:
      slot - the slot of the pane
      length - the length of the pane
      height - the height of the pane
      Since:
      0.10.8
    • StaticPane

      public StaticPane(int x, int y, int length, int height)
    • StaticPane

      public StaticPane(int length, int height)
  • Method Details

    • display

      public 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 If there are multiple items in the same position when displaying the items, either one of those items may be shown. In particular, there is no guarantee that a specific item will be shown.
      Specified by:
      display in class Pane
      Parameters:
      inventoryComponent - the inventory component in which the items should be displayed
      paneOffsetX - the pane's offset on the x axis
      paneOffsetY - the pane's offset on the y axis
      maxLength - the maximum length of the pane
      maxHeight - the maximum height of the pane
    • addItem

      public void addItem(@NotNull @NotNull GuiItem item, int x, int y)
      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 set
      x - the x coordinate of the position of the item
      y - the y coordinate of the position of the item
    • addItem

      public void addItem(@NotNull @NotNull GuiItem item, Slot slot)
      Adds a gui item at the specific spot in the pane. If the slot is specified in terms of an x and y coordinate pair and this pane contains another item whose position is specified as such and these positions are equal, the old item will be overwritten by this item. If the slot is specified in terms of an index and this pane contains another item whose position is specified as such and these positions are equal, the old item will be overwritten by this item.
      Parameters:
      item - the item to set
      slot - the position of the item
      Since:
      0.10.8
    • removeItem

      public void removeItem(@NotNull @NotNull GuiItem item)
      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 only remove items whose slot was specified in terms of an x and y coordinate pair which matches the coordinate specified.
      Parameters:
      x - the x coordinate of the item to remove
      y - the y coordinate of the item to remove
      Since:
      0.10.0
    • removeItem

      public void removeItem(@NotNull @NotNull Slot slot)
      Removes the specified item from the pane. This will only remove items whose slot was specified in the same way as the original slot and whose slot positions match.
      Parameters:
      slot - the slot of the item to remove
      Since:
      0.10.8
    • click

      public boolean click(@NotNull @NotNull Gui gui, @NotNull @NotNull InventoryComponent inventoryComponent, @NotNull @NotNull InventoryClickEvent event, int slot, int paneOffsetX, int paneOffsetY, int maxLength, int maxHeight)
      Description copied from class: Pane
      Called whenever there is being clicked on this pane
      Specified by:
      click in class Pane
      Parameters:
      gui - the gui in which was clicked
      inventoryComponent - the inventory component in which this pane resides
      event - the event that occurred while clicking on this item
      slot - the slot that was clicked in
      paneOffsetX - the pane's offset on the x axis
      paneOffsetY - the pane's offset on the y axis
      maxLength - the maximum length of the pane
      maxHeight - the maximum height of the pane
      Returns:
      whether the item was found or not
    • copy

      @NotNull @Contract(pure=true) public @NotNull StaticPane copy()
      Description copied from class: Pane
      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.
      Overrides:
      copy in class Pane
      Returns:
      a copy of this pane
    • setRotation

      public void setRotation(int rotation)
      Description copied from interface: Rotatable
      Sets 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:
      setRotation in interface Rotatable
      Parameters:
      rotation - the rotation of this pane, must be divisible by 90.
    • fillWith

      public void fillWith(@NotNull @NotNull ItemStack itemStack, @Nullable @Nullable Consumer<InventoryClickEvent> action, @NotNull @NotNull Plugin plugin)
      Fills all empty space in the pane with the given itemStack and adds the given action
      Parameters:
      itemStack - The ItemStack to fill the empty space with
      action - The action called whenever an interaction with the item happens
      plugin - 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<InventoryClickEvent> action)
      Fills all empty space in the pane with the given itemStack and adds the given action
      Parameters:
      itemStack - The ItemStack to fill the empty space with
      action - The action called whenever an interaction with the item happens
      Since:
      0.5.9
    • fillWith

      @Contract("null -> fail") public void fillWith(@NotNull @NotNull ItemStack itemStack)
      Fills all empty space in the pane with the given itemStack
      Parameters:
      itemStack - The ItemStack to fill the empty space with
      Since:
      0.2.4
    • getItems

      @NotNull public @NotNull Collection<GuiItem> getItems()
      Description copied from class: Pane
      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.)
      Specified by:
      getItems in class Pane
      Returns:
      all items
    • clear

      public void clear()
      Description copied from class: Pane
      Clears the entire pane of any items/panes. Underlying panes will not be cleared.
      Specified by:
      clear in class Pane
    • getPanes

      @NotNull @Contract(pure=true) public @NotNull Collection<Pane> getPanes()
      Description copied from class: Pane
      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.)
      Specified by:
      getPanes in class Pane
      Returns:
      all panes
    • flipHorizontally

      public void flipHorizontally(boolean flipHorizontally)
      Description copied from interface: Flippable
      Sets whether this pane should flip its items horizontally
      Specified by:
      flipHorizontally in interface Flippable
      Parameters:
      flipHorizontally - whether the pane should flip items horizontally
    • flipVertically

      public void flipVertically(boolean flipVertically)
      Description copied from interface: Flippable
      Sets whether this pane should flip its items vertically
      Specified by:
      flipVertically in interface Flippable
      Parameters:
      flipVertically - whether the pane should flip items vertically
    • getRotation

      @Contract(pure=true) public int getRotation()
      Description copied from interface: Rotatable
      Gets 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:
      getRotation in interface Rotatable
      Returns:
      the rotation for this pane
    • isFlippedHorizontally

      @Contract(pure=true) public boolean isFlippedHorizontally()
      Description copied from interface: Flippable
      Gets whether this pane's items are flipped horizontally
      Specified by:
      isFlippedHorizontally in interface Flippable
      Returns:
      true if the items are flipped horizontally, false otherwise
    • isFlippedVertically

      @Contract(pure=true) public boolean isFlippedVertically()
      Description copied from interface: Flippable
      Gets whether this pane's items are flipped vertically
      Specified by:
      isFlippedVertically in interface Flippable
      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 class
      element - the element
      plugin - the plugin that will be the owner of the udnerlying items
      Returns:
      the outline pane
      Since:
      0.10.8
    • load

      @NotNull @Deprecated public static @NotNull StaticPane load(@NotNull @NotNull Object instance, @NotNull @NotNull Element element)
      Deprecated.
      this method is no longer used internally and has been superseded by load(Object, Element, Plugin)
      Loads an outline pane from a given element
      Parameters:
      instance - the instance class
      element - the element
      Returns:
      the outline pane