Class StaticPane

java.lang.Object
me.despical.inventoryframework.pane.Pane
me.despical.inventoryframework.pane.StaticPane
All Implemented Interfaces:
Fillable, Flippable, Rotatable

public class StaticPane extends Pane implements Flippable, Rotatable, Fillable
A pane for static items and stuff. All items will have to be specified a slot, or will be added in the next position.
Since:
1.0.1

Created at 04.09.2020

Author:
Despical
  • Constructor Details

    • StaticPane

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

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

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

    • load

      @NotNull public static @NotNull StaticPane load(@NotNull @NotNull Object instance, @NotNull @NotNull Element element)
      Loads an outline pane from a given element
      Parameters:
      instance - the instance class
      element - the element
      Returns:
      the outline pane
    • display

      public void display(@NotNull @NotNull Gui gui, @NotNull @NotNull org.bukkit.inventory.Inventory inventory, @NotNull @NotNull org.bukkit.inventory.PlayerInventory playerInventory, int paneOffsetX, int paneOffsetY, int maxLength, int maxHeight)
      Description copied from class: Pane
      Has to set all the items in the right spot inside the inventory
      Specified by:
      display in class Pane
      Parameters:
      gui - the gui for which we're rendering
      inventory - the inventory that the items should be displayed in
      playerInventory - the player's inventory
      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 the coordinates as specified by the x and y parameters is already occupied, that item will be replaced by the item parameter.
      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, int slot)
      Adds a gui item at the specific spot in the pane. If the coordinates as specified by the x and y parameters is already occupied, that item will be replaced by the item parameter.
      Parameters:
      item - the item to set
      slot - the slot of the item
    • removeItem

      public void removeItem(@NotNull @NotNull GuiItem item)
      Removes the specified item from the pane
      Parameters:
      item - the item to remove
      Since:
      1.0.1
    • removeItem

      public void removeItem(int x, int y)
      Removes the specified item from the pane
      Parameters:
      x - the x axis of item to remove
      y - the y axis of item to remove
      Since:
      1.0.1
    • removeItem

      public void removeItem(int slot)
      Removes the specified item from the pane
      Parameters:
      slot - the slot of the item to remove
      Since:
      1.0.1
    • click

      public boolean click(@NotNull @NotNull Gui gui, @NotNull @NotNull org.bukkit.event.inventory.InventoryClickEvent event, 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 this event stems from
      event - the event that occurred while clicking on this item
      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
    • fillWith

      public void fillWith(@NotNull @NotNull org.bukkit.inventory.ItemStack itemStack, @Nullable @Nullable Consumer<org.bukkit.event.inventory.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:
      1.0.1
    • fillWith

      public void fillWith(@NotNull @NotNull org.bukkit.inventory.ItemStack itemStack)
      Fills all empty space in the pane with the given itemStack
      Parameters:
      itemStack - The ItemStack to fill the empty space with
      Since:
      1.0.1
    • fillHorizontallyWith

      public void fillHorizontallyWith(@NotNull @NotNull GuiItem guiItem, int line)
      Description copied from interface: Fillable
      Fills specified row line horizontally with given gui item.
      Specified by:
      fillHorizontallyWith in interface Fillable
      Parameters:
      guiItem - to fill the empty space with
      line - to fill with guiItem
    • fillVerticallyWith

      public void fillVerticallyWith(@NotNull @NotNull GuiItem guiItem, int line)
      Description copied from interface: Fillable
      Fills specified row line vertically with given gui item.
      Specified by:
      fillVerticallyWith in interface Fillable
      Parameters:
      guiItem - to fill the empty space with
      line - to fill with given gui item
    • fillBorder

      public void fillBorder(@NotNull @NotNull GuiItem guiItem)
      Description copied from interface: Fillable
      Fills inventory borders with given gui item.
      Specified by:
      fillBorder in interface Fillable
      Parameters:
      guiItem - to fill the empty space with
    • fillProgressBorder

      public void fillProgressBorder(@NotNull @NotNull GuiItem full, @NotNull @NotNull GuiItem empty, int progress)
      Description copied from interface: Fillable
      Fills inventory borders with given gui item.
      Specified by:
      fillProgressBorder in interface Fillable
      Parameters:
      full - to fill the progressed space with
      empty - to fill the empty space with
      progress - percentage of items to fill
    • 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
    • getLocations

      @NotNull public @NotNull Set<Map.Entry<Integer,Integer>> getLocations()
    • 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
    • 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.
    • 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