Interface ShopItem

All Superinterfaces:
Cloneable

public interface ShopItem extends Cloneable
Represents a buyable item in the shop
  • Method Details

    • getId

      String getId()
      Get the id of this item.

      Note that specifying the id in the configs file is optional file. If it's not specified, it'll be automatically generated. If auto-generated, then isIdAutogenerated() will return true.

      In case it is auto-generated, a combination of name, icon and page will be used.

      Returns:
      The id of the item. Unique towards other items, yet persistent after restarts
    • isIdAutogenerated

      boolean isIdAutogenerated()
      Get whether the id of this item has been auto-generated or not.
      Returns:
      true if the id has been auto-generated, otherwise false
      See Also:
    • getName

      String getName()
      Returns its unformatted name as it is in the config file.
      Returns:
      The name of the item
    • setName

      void setName(String name)
      Changes the name of this ShopItem.
      Parameters:
      name - the new name of this item
    • getDisplayName

      default String getDisplayName()
      Returns the formatted name of the item 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
    • getDescription

      @Nullable default @Nullable String getDescription()
      Returns the formatted description of the item in the default language.
      Returns:
      The description in the default language. May be null when it doesn't have one
    • getDescription

      @Nullable @Nullable String getDescription(@Nullable @Nullable CommandSender sender)
      Returns the formatted description in the language of the sender.
      Parameters:
      sender - The person
      Returns:
      The description in the language of the sender. May be null when it doesn't have one
    • getConfigDescription

      @Nullable @Nullable String getConfigDescription()
      Returns the unformatted description as it is written in the configs.
      Returns:
      The unformatted description. May be null when it doesn't have one
    • setConfigDescription

      void setConfigDescription(@Nullable @Nullable String description)
      Change the description of the item.
      Parameters:
      description - The new unformatted description. May be null
    • getPage

      ShopPage getPage()
      Returns the page in which the item is inside.
      Returns:
      The page in which the item has been added
    • getPrices

      List<? extends ShopPrice> getPrices()
      Returns the prices that will be taken from the player when he's trying to buy the item.
      Returns:
      The price for this item
    • getProducts

      List<? extends ShopProduct> getProducts()
      Returns the products that will be given to the buyer.
      Returns:
      The products of this item
    • addPriceItem

      ItemShopPrice addPriceItem(ItemStack price, int amount)
      Adds an ItemStack price to this instance.

      The type of the returned instance is equal to ShopPriceType.ITEM.

      Parameters:
      price - The material required for the purchase
      amount - The amount of material required for the purchase
      Returns:
      The price created and applied to the item
    • addPriceSpawner

      SpawnerItemShopPrice addPriceSpawner(DropType price, int amount)
      Adds a Spawner price to this instance.

      The type of the returned instance is equal to ShopPriceType.SPAWNER_ITEM.

      Parameters:
      price - The DropType required for the purchase
      amount - The amount of material required for the purchase
      Returns:
      The price created and applied to the item
    • removePrice

      boolean removePrice(ShopPrice price)
      Removes a price instance from this item.
      Parameters:
      price - The instance that shall be removed
      Returns:
      true if it's a part of this item and if it has been removed. Otherwise false
    • addProductCommand

      CommandShopProduct addProductCommand(String command, boolean executeAsConsole)
      Adds a product that executes a command when this item is being bought.

      The type of the returned instance is equal to ShopProductType.COMMAND.

      Parameters:
      command - The command that will be executed on a successful purchase
      executeAsConsole - Whether the command shall be executed as the console (true) or as the player (false)
      Returns:
      The product created and applied to the item
    • addProductItem

      ItemShopProduct addProductItem(ItemStack item, int amount)
      Adds a product that gives the player an ItemStack when this item is being bought.

      The type of the returned instance is equal to ShopProductType.ITEM.

      Parameters:
      item - The ItemStack the player will receive on a successful purchase
      amount - The amount of items the player will receive
      Returns:
      The product created and applied to the item
    • addProductSpawner

      SpawnerItemShopProduct addProductSpawner(DropType dropType, int amount)
      Adds a product that gives the player a spawner drops when this item is being bought.

      The type of the returned instance is equal to ShopProductType.ITEM.

      Parameters:
      dropType - The DropType the player will receive on a successful purchase
      amount - The amount of items the player will receive
      Returns:
      The product created and applied to the item
    • addProductSpecialItem

      SpecialItemShopProduct addProductSpecialItem(SpecialItem specialItem, int amount)
      Adds a product that gives the player a SpecialItem when this item is being bought.

      The type of the returned instance is equal to ShopProductType.ITEM.

      Parameters:
      specialItem - The special item that the player will receive when he buys the item
      amount - The amount of items the player will receive
      Returns:
      The product created and applied to the item
    • removeProduct

      boolean removeProduct(ShopProduct product)
      Removes a product instance from this item.
      Parameters:
      product - The instance that shall be removed
      Returns:
      true if it's a part of this item and if it has been removed. Otherwise false
    • 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
    • getCapsMultiply

      int getCapsMultiply()
      Get the max amount that'll be multiplied when shift-clicking the item in the shop.
      Returns:
      The caps-multiply
    • setCapsMultiply

      void setCapsMultiply(int capsMultiply)
      Set the max amount that'll be multiplied when shift-clicking the item in the shop.
      Parameters:
      capsMultiply - The new value
    • isKeptOnDeath

      boolean isKeptOnDeath()
      Returns whether the item will be kept when the player dies.
      Returns:
      If the item will be kept on death
    • setKeptOnDeath

      void setKeptOnDeath(boolean keepOnDeath)
      Define whether the item shall be kept on death.
      Parameters:
      keepOnDeath - The new value
    • isOneTimePurchase

      boolean isOneTimePurchase()
      Returns whether the item can be only bought once.
      Returns:
      If the item can only be bought once
    • setOneTimePurchase

      void setOneTimePurchase(boolean oneTimePurchase)
      Define whether the item can be only bought once.
      Parameters:
      oneTimePurchase - The new value
    • getBuyGroup

      @Nullable @Nullable BuyGroup getBuyGroup()
      Returns the buy-group of the item. Might be null if it isn't in any.
      Returns:
      The buy-group of this item
    • setBuyGroup

      void setBuyGroup(@Nullable @Nullable BuyGroup buyGroup)
      Set the new buy-group of this item or remove it from an existing one.
      Parameters:
      buyGroup - Its new buy-group, or null to remove it from the existing one
    • hasBuyGroup

      boolean hasBuyGroup()
      Returns if the item is a member of a buy-group or not.
      Returns:
      true if it has a buy-group, otherwise false
    • getBuyGroupLevel

      int getBuyGroupLevel()
      Returns the buy-group level of this item.

      It might be return a non -1 number even tho it's currently not in any buy-group.

      Returns:
      Its buy-group level
    • setBuyGroupLevel

      void setBuyGroupLevel(int level)
      Set the buy-group level of this item.

      The change is even being (temporarily) being applied even when it currently is not a member of one.

      Parameters:
      level - Its new buy-group level
    • hasBuyPermission

      boolean hasBuyPermission(Player player)
      Weather or not a player has permission to buy this item.
      Parameters:
      player - The player we want to check
    • setBuyPermissionId

      void setBuyPermissionId(@Nullable @Nullable String permissionId)
      Set a required buy permission for players. The full permission will look like 'shopitem.id' Can be null if there should be no buy permission
      Parameters:
      permissionId - The ID the custom buy permission should have. null is there should be none.
    • getBuyPermissionId

      @Nullable @Nullable String getBuyPermissionId()
      Get the required buy permission id for shop item purchase. The full permission will look like 'shopitem.id' Can be null if there is no buy permission set
      Returns:
      The id of the required by permission. null if there is no permission set.
    • 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 shouldn't do that
      Returns:
      The slot at which it shall be forced at
    • setForceSlot

      void setForceSlot(@Nullable @Nullable Integer forceSlot)
      Define at which it shall be forced at after the rendering of the shop GUI
      Can be null if it shouldn't do that
      Parameters:
      forceSlot - The new value
    • getRestriction

      @Nullable @Nullable ArenaConditionGroup getRestriction()
      The ArenaConditionGroup that controls what arenas this ShopItem is visible in.
      Returns:
      The condition that states the arenas this ShopItem will be available in. null if the ShopItem should be displayed in every arena.
    • setRestriction

      void setRestriction(@Nullable @Nullable ArenaConditionGroup restriction)
      Lets you restrict this ShopItem, so only be available in certain arenas
      Parameters:
      restriction - The condition that states the arenas this ShopItem will be available in. null if the ShopItem should be displayed in every arena.
    • calcPurchasableQuantity

      int calcPurchasableQuantity(Player player, @Nullable @Nullable ItemStack[] inv)
      Returns the amount of how often the player could purchase this item in the invoked moment
      Parameters:
      player - The player we want to check
      inv - The theoretical inventory from which it shall be taken. null if it shall use the players inventory
      Returns:
      The quantity of purchase instances the player could theoretically have in this moment
    • calcPurchasableQuantity

      default int calcPurchasableQuantity(Player player)
      Returns the amount of how often the player could purchase this item in the invoked moment
      Parameters:
      player - The player we want to check
      Returns:
      The quantity of purchase instances the player could theoretically have in this moment
    • buy

      PlayerBuyInShopEvent buy(Player player, boolean isShiftClick)
      Make the player buy the item.

      Note that it will automatically make use of getOriginal(), as it is not possible to buy cloned items. Procedure is exactly the same as if the player would click by himself on the given item.

      Parameters:
      player - The player who is supposed to
      isShiftClick - Whether he held shift during the purchase (Meaning that it's supposed to bought in stacks)
      Returns:
      The result of the purchase
    • isClone

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

      ShopItems 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

      ShopItem 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

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