Interface ShopPage

All Superinterfaces:
Cloneable

public interface ShopPage extends Cloneable
Represents a page in the shop that contains a collection of items
  • Method Details

    • getName

      String getName()
      Returns the unformatted name.
      Returns:
      The name of the page
    • getDisplayName

      default String getDisplayName()
      Returns the formatted name of the page in the default language.
      Returns:
      The display name in the default language
    • getDisplayName

      String getDisplayName(@Nullable @Nullable CommandSender sender)
      Returns the formatted name in the language of the sender.
      Parameters:
      sender - The person
      Returns:
      The display name in the language of the sender
    • getIcon

      ItemStack getIcon()
      Returns the icon that will be shown in the shop GUI.
      Returns:
      The icon
    • setIcon

      void setIcon(ItemStack icon)
      Set the icon that shall be shown in the shop GUI.
      Parameters:
      icon - The new icon
    • getItems

      List<? extends ShopItem> getItems()
      Returns all the possible items that are inside the page.

      All will be cloned as well if this page has been cloned beforehand (isClone()).

      Returns:
      All items that the page has
    • getVisiblePageItems

      List<? extends ShopItem> getVisiblePageItems(@Nullable @Nullable Arena arena, @Nullable @Nullable Player player)
      Returns the items that are inside the page for a specific player.
      Parameters:
      arena - The arena the player is in
      player - The player
      Returns:
      All items visible to the player
    • removeItem

      boolean removeItem(ShopItem shopItem)
      Removes an item from this shop page.

      Note that both instances must have the same reference. If you try to remove a cloned shopItem using a non-cloned or vice versa, then you might want to use removeConnectedItems(ShopItem) instead.

      Parameters:
      shopItem - the item that you are trying to remove
      Returns:
      true if it was successfully removed
    • removeConnectedItems

      int removeConnectedItems(ShopItem shopItem)
      Removes all ShopItems that share the original instance.

      As it is possible to insert multiple ShopItems into a page that share the original instance (e.g. you inserted a non-cloned ShopItem and a ShopItem that has been cloned using that other ShopItem), it might be annoying to find all similar instance. This methods helps you to get easily rid of them.

      Parameters:
      shopItem - The ShopItem or whose original instance whose clones we want to remove
      Returns:
      The amount of items that got found and removed
    • addItem

      boolean addItem(ShopItem shopItem)
      Adds an item to a shop page.
      Parameters:
      shopItem - the item that you are trying to remove
      Returns:
      true if it was successfully removed
      Throws:
      IllegalStateException - If you pass a non-cloned item if this instance has been cloned (isClone() returns true)
    • addItem

      ShopItem addItem(String name, ItemStack icon)
      Constructs a new ShopItem, and adds it to the ShopPage.
      Parameters:
      name - The name of the item you are attempting to create
      icon - The ItemStack that will be displayed as the icon in the shop
      Returns:
      The new item created, and added to the shop
    • getForceSlot

      @Nullable @Nullable Integer getForceSlot()
      Returns the slot at which it'll be placed at after the rendering of the shop layout GUI.

      Can be null if it is not supposed to have this behaviour.

      Returns:
      The slot at which it shall be forced at
    • setForceSlot

      void setForceSlot(@Nullable @Nullable Integer forceSlot)
      Define at which slot the item shall be forced at after the rendering of the shop GUI.

      Can be null if it is not supposed to have this behaviour.

      Parameters:
      forceSlot - The new value
    • isClone

      boolean isClone()
      Checks whether this instance is a clone (as if it has been cloned using clone()).

      ShopPages are cloned in some cases (e.g. when a shop is opened) to allow you to modify the shop without affecting other arenas.

      Returns:
      whether this BuyGroup is a clone
      See Also:
    • getOriginal

      ShopPage getOriginal()
      Returns the original "non-cloned" instance.

      This will return the original instance from which the clone has been created from. In case isClone() returns false, the same instance is being returned.

      Returns:
      The original non-cloned instance
      See Also:
    • clone

      ShopPage clone()
      Returns a clone of this instance.
      Returns:
      A clone of this instance
      See Also: