Class BaseGUI

java.lang.Object
de.studiocode.invui.gui.impl.BaseGUI
All Implemented Interfaces:
Controllable, GUI, GUIParent
Direct Known Subclasses:
PagedGUI, ScrollGUI, SimpleGUI, TabGUI

public abstract class BaseGUI extends Object implements GUI, Controllable
  • Constructor Details

    • BaseGUI

      public BaseGUI(int width, int height)
  • Method Details

    • handleClick

      public void handleClick(int slotNumber, org.bukkit.entity.Player player, org.bukkit.event.inventory.ClickType clickType, org.bukkit.event.inventory.InventoryClickEvent event)
      Description copied from interface: GUI
      A method called if a slot in the Inventory has been clicked.
      Specified by:
      handleClick in interface GUI
      Parameters:
      slotNumber - The slot that has been clicked
      player - The Player that clicked
      clickType - The ClickType
      event - The InventoryClickEvent
    • handleVISlotElementClick

      protected void handleVISlotElementClick(SlotElement.VISlotElement element, org.bukkit.event.inventory.InventoryClickEvent event)
    • handleVILeftClick

      protected void handleVILeftClick(org.bukkit.event.inventory.InventoryClickEvent event, VirtualInventory inventory, int slot, org.bukkit.entity.Player player, org.bukkit.inventory.ItemStack clicked, org.bukkit.inventory.ItemStack cursor)
    • handleVIRightClick

      protected void handleVIRightClick(org.bukkit.event.inventory.InventoryClickEvent event, VirtualInventory inventory, int slot, org.bukkit.entity.Player player, org.bukkit.inventory.ItemStack clicked, org.bukkit.inventory.ItemStack cursor)
    • handleVIItemShift

      protected void handleVIItemShift(org.bukkit.event.inventory.InventoryClickEvent event, VirtualInventory inventory, int slot, org.bukkit.entity.Player player, org.bukkit.inventory.ItemStack clicked)
    • handleVINumberKey

      protected void handleVINumberKey(org.bukkit.event.inventory.InventoryClickEvent event, VirtualInventory inventory, int slot, org.bukkit.entity.Player player, org.bukkit.inventory.ItemStack clicked)
    • handleVIOffHandKey

      protected void handleVIOffHandKey(org.bukkit.event.inventory.InventoryClickEvent event, VirtualInventory inventory, int slot, org.bukkit.entity.Player player, org.bukkit.inventory.ItemStack clicked)
    • handleVIDrop

      protected void handleVIDrop(boolean ctrl, org.bukkit.event.inventory.InventoryClickEvent event, VirtualInventory inventory, int slot, org.bukkit.entity.Player player, org.bukkit.inventory.ItemStack clicked)
    • handleVIDoubleClick

      protected void handleVIDoubleClick(org.bukkit.event.inventory.InventoryClickEvent event, VirtualInventory inventory, org.bukkit.entity.Player player, org.bukkit.inventory.ItemStack cursor)
    • handleItemDrag

      public boolean handleItemDrag(UpdateReason updateReason, int slot, org.bukkit.inventory.ItemStack oldStack, org.bukkit.inventory.ItemStack newStack)
      Description copied from interface: GUI
      A method called when an ItemStack has been dragged over the GUI.
      Specified by:
      handleItemDrag in interface GUI
      Parameters:
      updateReason - The reason for this item update.
      slot - The slot index
      oldStack - The ItemStack that was previously on that slot
      newStack - The new ItemStack that would be there if the action isn't cancelled
      Returns:
      If the action has been cancelled
    • handleItemShift

      public void handleItemShift(org.bukkit.event.inventory.InventoryClickEvent event)
      Description copied from interface: GUI
      A method called when an ItemStack has been shift-clicked into this GUI.
      Specified by:
      handleItemShift in interface GUI
      Parameters:
      event - The InventoryClickEvent associated with this action
    • putIntoFirstVirtualInventory

      protected int putIntoFirstVirtualInventory(UpdateReason updateReason, org.bukkit.inventory.ItemStack itemStack, VirtualInventory... ignored)
    • getAllVirtualInventories

      protected LinkedHashSet<VirtualInventory> getAllVirtualInventories(VirtualInventory... ignored)
    • handleSlotElementUpdate

      public void handleSlotElementUpdate(GUI child, int slotIndex)
      Description copied from interface: GUIParent
      Called by the child GUI to report an update of a SlotElement.
      Specified by:
      handleSlotElementUpdate in interface GUIParent
      Parameters:
      child - The child GUI whose SlotElement has changed
      slotIndex - The slot index of the changed SlotElement in the child GUI
    • addParent

      public void addParent(@NotNull @NotNull GUIParent parent)
      Description copied from interface: GUI
      Adds a GUIParent to the set of GUIParents.
      Specified by:
      addParent in interface GUI
      Parameters:
      parent - The GUIParent to add
    • removeParent

      public void removeParent(@NotNull @NotNull GUIParent parent)
      Description copied from interface: GUI
      Removes a GUIParent from the set of GUIParents
      Specified by:
      removeParent in interface GUI
      Parameters:
      parent - The GUIParent to remove
    • getParents

      public Set<GUIParent> getParents()
      Description copied from interface: GUI
      Gets all GUIParents.
      Specified by:
      getParents in interface GUI
      Returns:
      The GUIParents of this GUI
    • findAllWindows

      public List<Window> findAllWindows()
      Description copied from interface: GUI
      Finds all Windows that show this GUI.
      Specified by:
      findAllWindows in interface GUI
      Returns:
      The list of Window that show this GUI
    • findAllCurrentViewers

      public Set<org.bukkit.entity.Player> findAllCurrentViewers()
      Description copied from interface: GUI
      Finds all Players that are currently seeing this Window.
      Specified by:
      findAllCurrentViewers in interface GUI
      Returns:
      The list of Players that are currently seeing this Window
    • closeForAllViewers

      public void closeForAllViewers()
      Description copied from interface: GUI
      Closes the open Inventory for all viewers of Windows where this GUI is displayed. Does not actually call the Window.close(boolean) method, which will be indirectly invoked by the InventoryCloseEvent if the Window is set to close on that event.
      Specified by:
      closeForAllViewers in interface GUI
    • playAnimation

      public void playAnimation(@NotNull @NotNull Animation animation, @Nullable @Nullable Predicate<SlotElement> filter)
      Description copied from interface: GUI
      Plays an Animation.
      Specified by:
      playAnimation in interface GUI
      Parameters:
      animation - The Animation to play.
      filter - The filter that selects which SlotElements should be animated.
    • cancelAnimation

      public void cancelAnimation()
      Description copied from interface: GUI
      Cancels the running Animation if there is one.
      Specified by:
      cancelAnimation in interface GUI
    • updateControlItems

      public void updateControlItems()
      Specified by:
      updateControlItems in interface Controllable
    • setSlotElement

      public void setSlotElement(int index, SlotElement slotElement)
      Description copied from interface: GUI
      Sets the SlotElement on these coordinates. If you need to set an Item, please use GUI.setItem(int, Item) instead.
      Specified by:
      setSlotElement in interface GUI
      Parameters:
      index - The slot index
      slotElement - The SlotElement to be placed there.
    • getSlotElement

      public SlotElement getSlotElement(int index)
      Description copied from interface: GUI
      Gets the SlotElement placed on that slot.
      Specified by:
      getSlotElement in interface GUI
      Parameters:
      index - The slot index
      Returns:
      The SlotElement placed on that slot
    • hasSlotElement

      public boolean hasSlotElement(int index)
      Description copied from interface: GUI
      Gets if there is a SlotElement placed on that slot.
      Specified by:
      hasSlotElement in interface GUI
      Parameters:
      index - The slot index
      Returns:
      If there is a SlotElement placed there
    • getSlotElements

      public SlotElement[] getSlotElements()
      Description copied from interface: GUI
      Gets all SlotElements of this GUI in an Array.
      Specified by:
      getSlotElements in interface GUI
      Returns:
      All SlotElements of this GUI
    • setItem

      public void setItem(int index, Item item)
      Description copied from interface: GUI
      Sets the Item on that slot
      Specified by:
      setItem in interface GUI
      Parameters:
      index - The slot index
      item - The Item that should be placed on that slot or null to remove the Item that is currently there.
    • addItems

      public void addItems(@NotNull @NotNull Item... items)
      Description copied from interface: GUI
      Adds Items to the gui.
      Specified by:
      addItems in interface GUI
      Parameters:
      items - The Items that should be added to the gui
    • getItem

      public Item getItem(int index)
      Description copied from interface: GUI
      Gets the Item placed on that slot.
      Specified by:
      getItem in interface GUI
      Parameters:
      index - The slot index
      Returns:
      The Item which is placed on that slot or null if there isn't one
    • getBackground

      public ItemProvider getBackground()
      Description copied from interface: GUI
      Gets the ItemProvider that will be used if nothing else is placed on a slot.
      Specified by:
      getBackground in interface GUI
      Returns:
      The ItemProvider
    • setBackground

      public void setBackground(ItemProvider itemProvider)
      Description copied from interface: GUI
      Sets the ItemProvider that will be used if nothing else is placed on a slot.
      Specified by:
      setBackground in interface GUI
      Parameters:
      itemProvider - The ItemProvider
    • remove

      public void remove(int index)
      Description copied from interface: GUI
      Remove the Item which are placed on these slots.
      Specified by:
      remove in interface GUI
      Parameters:
      index - The slot index of the Items that should be removed
    • applyStructure

      public void applyStructure(Structure structure)
      Description copied from interface: GUI
      Applies the given Structure to the GUI.
      Specified by:
      applyStructure in interface GUI
      Parameters:
      structure - The structure
    • getSize

      public int getSize()
      Description copied from interface: GUI
      Gets the size of the GUI.
      Specified by:
      getSize in interface GUI
      Returns:
      The size of the gui.
    • setSlotElement

      public void setSlotElement(int x, int y, SlotElement slotElement)
      Description copied from interface: GUI
      Sets the SlotElement on these coordinates. If you need to set an Item, please use GUI.setItem(int, int, Item) instead.
      Specified by:
      setSlotElement in interface GUI
      Parameters:
      x - The x coordinate
      y - The y coordinate
      slotElement - The SlotElement to be placed there.
    • getSlotElement

      public SlotElement getSlotElement(int x, int y)
      Description copied from interface: GUI
      Gets the SlotElement on these coordinates.
      Specified by:
      getSlotElement in interface GUI
      Parameters:
      x - The x coordinate
      y - The y coordinate
      Returns:
      The SlotElement placed there
    • hasSlotElement

      public boolean hasSlotElement(int x, int y)
      Description copied from interface: GUI
      Gets if there is a SlotElement on these coordinates.
      Specified by:
      hasSlotElement in interface GUI
      Parameters:
      x - The x coordinate
      y - The y coordinate
      Returns:
      If there is a SlotElement placed there
    • setItem

      public void setItem(int x, int y, Item item)
      Description copied from interface: GUI
      Sets the Item on these coordinates.
      Specified by:
      setItem in interface GUI
      Parameters:
      x - The x coordinate
      y - The y coordinate
      item - The Item that should be placed on these coordinates or null to remove the Item that is currently there.
    • getItem

      public Item getItem(int x, int y)
      Description copied from interface: GUI
      Gets the Item on these coordinates.
      Specified by:
      getItem in interface GUI
      Parameters:
      x - The x coordinate
      y - The y coordinate
      Returns:
      The Item which is placed on that slot or null if there isn't one
    • remove

      public void remove(int x, int y)
      Description copied from interface: GUI
      Removes an Item by its coordinates.
      Specified by:
      remove in interface GUI
      Parameters:
      x - The x coordinate
      y - The y coordinate
    • getWidth

      public int getWidth()
      Description copied from interface: GUI
      Gets the width of the GUI
      Specified by:
      getWidth in interface GUI
      Returns:
      The width of the GUI
    • getHeight

      public int getHeight()
      Description copied from interface: GUI
      Gets the height of the GUI
      Specified by:
      getHeight in interface GUI
      Returns:
      The height of the GUI
    • fill

      public void fill(@NotNull @NotNull Set<Integer> slots, @Nullable @Nullable Item item, boolean replaceExisting)
    • fill

      public void fill(int start, int end, @Nullable @Nullable Item item, boolean replaceExisting)
      Description copied from interface: GUI
      Fills the GUI with Items.
      Specified by:
      fill in interface GUI
      Parameters:
      start - The start index of the fill (inclusive)
      end - The end index of the fill (exclusive)
      item - The Item that should be used or null to remove an existing item.
      replaceExisting - If existing Items should be replaced.
    • fill

      public void fill(@Nullable @Nullable Item item, boolean replaceExisting)
      Description copied from interface: GUI
      Fills the entire GUI with Items.
      Specified by:
      fill in interface GUI
      Parameters:
      item - The Item that should be used or null to remove an existing item.
      replaceExisting - If existing Items should be replaced.
    • fillRow

      public void fillRow(int row, @Nullable @Nullable Item item, boolean replaceExisting)
      Description copied from interface: GUI
      Fills one row with a specific Item
      Specified by:
      fillRow in interface GUI
      Parameters:
      row - The row
      item - The Item that should be used or null to remove an existing item.
      replaceExisting - If existing Items should be replaced.
    • fillColumn

      public void fillColumn(int column, @Nullable @Nullable Item item, boolean replaceExisting)
      Description copied from interface: GUI
      Fills one column with a specific Item
      Specified by:
      fillColumn in interface GUI
      Parameters:
      column - The column
      item - The Item that should be used or null to remove an existing item.
      replaceExisting - If existing Items should be replaced.
    • fillBorders

      public void fillBorders(@Nullable @Nullable Item item, boolean replaceExisting)
      Description copied from interface: GUI
      Fills the borders of this GUI with a specific Item
      Specified by:
      fillBorders in interface GUI
      Parameters:
      item - The Item that should be used or null to remove an existing item.
      replaceExisting - If existing Items should be replaced.
    • fillRectangle

      public void fillRectangle(int x, int y, int width, int height, @Nullable @Nullable Item item, boolean replaceExisting)
      Description copied from interface: GUI
      Fills a rectangle in this GUI with a specific Item
      Specified by:
      fillRectangle in interface GUI
      Parameters:
      x - The x coordinate where the rectangle should start.
      y - The y coordinate where the rectangle should start.
      width - The width of the rectangle.
      height - The height of the rectangle
      item - The Item that should be used or null to remove an existing item.
      replaceExisting - If existing Items should be replaced.
    • fillRectangle

      public void fillRectangle(int x, int y, @NotNull @NotNull GUI gui, boolean replaceExisting)
      Description copied from interface: GUI
      Fills a rectangle of another GUI in this GUI.
      Specified by:
      fillRectangle in interface GUI
      Parameters:
      x - The x coordinate where the rectangle should start
      y - The y coordinate where the rectangle should start
      gui - The GUI to be put into this GUI
      replaceExisting - If existing SlotElements should be replaced.
    • fillRectangle

      public void fillRectangle(int x, int y, int width, @NotNull @NotNull VirtualInventory virtualInventory, boolean replaceExisting)
      Description copied from interface: GUI
      Fills a rectangle of a VirtualInventory in this GUI.
      Specified by:
      fillRectangle in interface GUI
      Parameters:
      x - The x coordinate where the rectangle should start
      y - The y coordinate where the rectangle should start
      width - The line length of the rectangle. (VirtualInventory does not define a width)
      virtualInventory - The VirtualInventory to be put into this GUI.
      replaceExisting - If existing SlotElements should be replaced.
    • fillRectangle

      public void fillRectangle(int x, int y, int width, @NotNull @NotNull VirtualInventory virtualInventory, @Nullable @Nullable ItemProvider background, boolean replaceExisting)
      Description copied from interface: GUI
      Fills a rectangle of a VirtualInventory in this GUI.
      Specified by:
      fillRectangle in interface GUI
      Parameters:
      x - The x coordinate where the rectangle should start
      y - The y coordinate where the rectangle should start
      width - The line length of the rectangle. (VirtualInventory does not define a width)
      virtualInventory - The VirtualInventory to be put into this GUI.
      background - The ItemProvider for empty slots of the VirtualInventory
      replaceExisting - If existing SlotElements should be replaced.