Class PlayerOpenShopEvent

java.lang.Object
org.bukkit.event.Event
org.bukkit.event.player.PlayerEvent
de.marcely.bedwars.api.event.player.PlayerOpenShopEvent
All Implemented Interfaces:
ArenaEvent, Cancellable

public class PlayerOpenShopEvent extends PlayerEvent implements ArenaEvent, Cancellable
Gets called when the player is opening the shop or when he's clicking on a page in the GUI
  • Constructor Details

  • Method Details

    • getArena

      @Nullable public @Nullable Arena getArena()
      Returns the arena (of the player) in which the shop was opened.

      May be null if the player isn't actually a part of a match as he e.g. used /bw tools to open and debug it.

      Specified by:
      getArena in interface ArenaEvent
      Returns:
      The arena in which the shop was opened
    • getLayout

      public ShopLayout getLayout()
      Returns the layout that will be used for the GUI.
      Returns:
      The layout that shall be shown
    • setLayout

      public void setLayout(ShopLayout layout)
      Set the layout of the shop GUI that shall be shown.
      Parameters:
      layout - The layout that shall be shown to the player
    • getClonedPage

      @Nullable public @Nullable ShopPage getClonedPage()
      Returns the cloned page that was opened.

      Is may returns null when the shop was opened the first time. In this case, it will likely open the main page (what exactly happens depends on the layout).

      Note that this the page will always be cloned, that is because to give the layout more freedom in designing the GUIs without affecting the original states. You may use ShopPage.getOriginal() to get the non-cloned page.

      Returns:
      The page that shall be shown
    • setPage

      public void setPage(@Nullable @Nullable ShopPage page)
      Sets the page that shall be opened.

      Is may be null when the shop was opened the first time. In this case, it will likely open the main page (what exactly happens depends on the layout).

      This method also automatically clones the page if it hasn't been already.

      Parameters:
      page - The new page
    • getItems

      @Nullable public @Nullable List<? extends ShopItem> getItems()
      Gets all the items that the player would theoretically see in the GUI.

      May be null if getClonedPage() returns null as well.

      Returns:
      The items that the player would see in the GUI
    • removeShopItem

      public boolean removeShopItem(ShopItem shopItem)
      Tries to remove a shop item and causes it to not be seen.
      Parameters:
      shopItem - The shopItem that shall be removed
      Returns:
      true if it has been removed
      Throws:
      IllegalStateException - If the shopItem is not cloned
    • addShopItem

      public boolean addShopItem(ShopItem shopItem)
      Tries to add a shopItem.
      Parameters:
      shopItem - The cloned shopItem that shall be added
      Returns:
      true if it has been successfully added
      Throws:
      IllegalStateException - If the shopItem is not cloned
    • getLayoutData

      @Nullable public @Nullable Object getLayoutData()
      A layout may hold and pass around data during its session.

      This might be useful when you're trying to manipulate the layout.

      Returns:
      The layout specific data
    • setLayoutData

      public void setLayoutData(@Nullable @Nullable Object layoutData)
      A layout may hold and pass around data during its session.

      This might be useful when you're trying to manipulate the layout. Keep in mind that errors might occur with the layout when inserting unexpected data.

      Parameters:
      layoutData - The new layout data
    • getCause

      public ShopOpenCause getCause()
      Returns the way how the player opened the shop
      Returns:
      The cause of the opening
    • isCancelled

      public boolean isCancelled()
      Specified by:
      isCancelled in interface Cancellable
    • setCancelled

      public void setCancelled(boolean bool)
      Specified by:
      setCancelled in interface Cancellable
    • getHandlers

      public HandlerList getHandlers()
      Specified by:
      getHandlers in class Event
    • getHandlerList

      public static HandlerList getHandlerList()