Class VillagerGUI

java.lang.Object
de.marcely.bedwars.tools.gui.type.VillagerGUI
All Implemented Interfaces:
GUI

public class VillagerGUI extends Object implements GUI
  • Constructor Details

    • VillagerGUI

      public VillagerGUI()
    • VillagerGUI

      public VillagerGUI(String title)
  • Method Details

    • open

      public void open(Player player)
      Description copied from interface: GUI
      Opens the GUI for the player
      Specified by:
      open in interface GUI
      Parameters:
      player - The player who shall see the inventory
    • closeAll

      public void closeAll()
      Description copied from interface: GUI
      Closes this GUI for any player
      Specified by:
      closeAll in interface GUI
    • setTitle

      public void setTitle(String title)
      Description copied from interface: GUI
      Set the title of the GUI. Keep in mind that not every type supports this
      Specified by:
      setTitle in interface GUI
      Parameters:
      title - The new title
    • getTitle

      public String getTitle()
      Description copied from interface: GUI
      Returns the set title
      Specified by:
      getTitle in interface GUI
      Returns:
      The title
    • areItemsMoveable

      public boolean areItemsMoveable()
      Description copied from interface: GUI
      Returns if this type allows its items to get moved around and to be dropped
      Specified by:
      areItemsMoveable in interface GUI
      Returns:
      If the items are moveable/dragable
    • getPlayers

      public Collection<Player> getPlayers()
      Description copied from interface: GUI
      Returns the player for whom the GUI is currently open
      Specified by:
      getPlayers in interface GUI
      Returns:
      The players for who the GUI has been opened
    • hasOpen

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

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

      public boolean removeCloseListener(Consumer<Player> callback)
      Description copied from interface: GUI
      Removes a close listener from the gui.
      Specified by:
      removeCloseListener in interface GUI
      Parameters:
      callback - the listener that is being removed
      Returns:
      if the listener was removed successfully
    • clear

      public void clear()
      Description copied from interface: GUI
      Resets its content
      Specified by:
      clear in interface GUI
    • onClose

      public final void onClose(Player player)
      Description copied from interface: GUI
      Event method that's getting called whenever a player closes the inventory
      Specified by:
      onClose in interface GUI
      Parameters:
      player - The player who closed the GUI
    • getOffers

      public Set<VillagerOffer> getOffers()
      Returns all offers that have been added to this GUI.
      Returns:
      All added offers
    • getOffer

      @Nullable public @Nullable VillagerOffer getOffer(UUID id)
      Returns the offer in this GUI whose id is equal to the given as a parameter
      Parameters:
      id - The id of the offer
      Returns:
      The offer whose id is equal. null if there's none
    • addOffer

      public boolean addOffer(VillagerOffer offer)
      Adds an offer that can be bought by a player.

      Keep in mind that you'll have to reopen the GUI for it to get updated.

      Parameters:
      offer - The buyable offer given to the player
      Returns:
      false if the offer has been already added before
    • removeOffer

      public boolean removeOffer(VillagerOffer offer)
      Removes an existing offer.

      Keep in mind that you'll have to reopen the GUI for it to get updated.

      Parameters:
      offer - The offer that shall be removed
      Returns:
      true if it has been removed
    • getTradeListeners

      public Set<Consumer<PlayerTradeVillagerGUIEvent>> getTradeListeners()
      Returns all registered trade events that were explicitly added to this GUI.

      Keep in mind that those listeners get run AFTER Bukkit's event queue. Cancelling them causes these listeners to noWt get run.

      It's safe to modify the returned set.

      Returns:
      All registered trade events that were explicitly added to this GUI
    • registerTradeListener

      public boolean registerTradeListener(Consumer<PlayerTradeVillagerGUIEvent> listener)
      Registers a listener that will be called when a player successfully executes a trade.

      Keep in mind that the listener get run AFTER Bukkit's event queue. Cancelling them causes these listeners to noWt get run.

      Parameters:
      listener - The listener that shall be registered
      Returns:
      true if it's not already registered
    • unregisterTradeListener

      public boolean unregisterTradeListener(Consumer<PlayerTradeVillagerGUIEvent> listener)
      Unregisters an already registered trade listener
      Parameters:
      listener - The listener that shall be unregistered
      Returns:
      false if it's not registered