Interface GUI

All Known Subinterfaces:
ClickableGUI
All Known Implementing Classes:
AnvilGUI, ChestGUI, VillagerGUI

public interface GUI
Interface that includes anything that any kind of GUI have in common
  • Method Details

    • open

      void open(Player player)
      Opens the GUI for the player
      Parameters:
      player - The player who shall see the inventory
    • closeAll

      void closeAll()
      Closes this GUI for any player
    • setTitle

      void setTitle(String title)
      Set the title of the GUI. Keep in mind that not every type supports this
      Parameters:
      title - The new title
    • getTitle

      String getTitle()
      Returns the set title
      Returns:
      The title
    • areItemsMoveable

      boolean areItemsMoveable()
      Returns if this type allows its items to get moved around and to be dropped
      Returns:
      If the items are moveable/dragable
    • ignoresCancelEvent

      default boolean ignoresCancelEvent()
      Ignore it. Only for internal use
      Returns:
      Something you probably don't need
    • getPlayers

      Collection<Player> getPlayers()
      Returns the player for whom the GUI is currently open
      Returns:
      The players for who the GUI has been opened
    • hasOpen

      boolean hasOpen(Player player)
      Get whether the given player has the inventory currently open
      Parameters:
      player - The player who might have the GUI open
      Returns:
      true if he's seeing it right now
    • addCloseListener

      boolean addCloseListener(Consumer<Player> callback)
      Adds a close listener to the gui. This listener will be called when a player closes the gui
      Parameters:
      callback - the listener that is being added
      Returns:
      if the listener was added successfully
    • removeCloseListener

      boolean removeCloseListener(Consumer<Player> callback)
      Removes a close listener from the gui.
      Parameters:
      callback - the listener that is being removed
      Returns:
      if the listener was removed successfully
    • getCloseListeners

      Collection<Consumer<Player>> getCloseListeners()
      Gets all the close listeners attached to the GUI
      Returns:
      a collection of all the attached listeners
    • clear

      void clear()
      Resets its content
    • onClose

      @Deprecated default void onClose(Player player)
      Deprecated.
      Poor API implementation. Not using #super(player) with AnvilGUI and VillagerGUI can cause memory leaks. Use addCloseListener(Consumer) instead
      Event method that's getting called whenever a player closes the inventory
      Parameters:
      player - The player who closed the GUI