Class Openable

java.lang.Object
Kyu.GuiAPI_Redone.Window.Openable
Direct Known Subclasses:
MultiWindow, TextWindow, TradeWindowHolder, Window

public abstract class Openable extends Object
  • Field Details

    • onClose

      protected Consumer<org.bukkit.event.inventory.InventoryCloseEvent> onClose
    • disableClickEvent

      protected boolean disableClickEvent
    • isIgnoreCloseEvent

      protected boolean isIgnoreCloseEvent
    • preventClose

      protected boolean preventClose
    • unregisterOnClose

      protected boolean unregisterOnClose
    • gui

      protected GUI gui
  • Constructor Details

    • Openable

      public Openable(GUI gui)
  • Method Details

    • open

      public abstract void open()
    • isDisableClickEvent

      public boolean isDisableClickEvent()
      Whether or not to cancel the OnInventoryClick event, preventing users from taking/placing items from the inventory
      Returns:
      whether disableClickEvent is on or off
    • setDisableClickEvent

      public void setDisableClickEvent(boolean disableClickEvent)
      Set whether or not InventoryClickEvent is canceled or not. Canceling prevents users from taking/placing items from the inventory
      Parameters:
      disableClickEvent - Whether or not to cancel InventoryClickEvent
    • isPreventClose

      public boolean isPreventClose()
      Returns:
      Whether or not the user can close the window with ESC
    • setPreventClose

      public void setPreventClose(boolean preventClose)
      Parameters:
      preventClose - Whether or not the user shall be able to close the window with ESC
    • isIgnoreCloseEvent

      public boolean isIgnoreCloseEvent()
      Returns:
      Whether or not the close Event will be ignored. If true, the onClose Consumer will not be called
    • setIgnoreCloseEvent

      public void setIgnoreCloseEvent(boolean isIgnoreCloseEvent)
      Parameters:
      isIgnoreCloseEvent - Whether or not the close Event will be ignored. If true, the onClose Consumer will not be called Keep in mind that setting this to true will also result in the WindowListener not being unregistered on Inventory closed, so you will have to handle this manually
    • getOnClose

      public Consumer<org.bukkit.event.inventory.InventoryCloseEvent> getOnClose()
      Returns:
      Function to call when the inventory gets closed and isIgnoreCloseEvent() is False. Or Null if no function is set
    • setOnClose

      public void setOnClose(Consumer<org.bukkit.event.inventory.InventoryCloseEvent> onClose)
      Parameters:
      onClose - Function to call when the inventory gets closed and isIgnoreCloseEvent() as well as isPreventClose() are False. Automatically disables isPreventClose() and isUnregisterOnClose() so you have to manually call GUI.unregisterListener() when your Windows are closed
    • setUnregisterOnClose

      public void setUnregisterOnClose(boolean unregisterOnClose)
      Parameters:
      unregisterOnClose - Set whether or not to automatically unregister the listeners when the window is closed and no setOnClose(Consumer) is set
    • isUnregisterOnClose

      public boolean isUnregisterOnClose()
      Returns:
      Whether or not to automatically unregister the listeners when the window is closed and no setOnClose(Consumer) is set
    • getGui

      public GUI getGui()
      Returns:
      The GUI the Window is connected to