Interface ShopPrice

All Known Subinterfaces:
ItemShopPrice, SpawnerItemShopPrice

public interface ShopPrice
  • Method Details

    • getItem

      ShopItem getItem()
      Returns the item to which the price has been added to
      Returns:
      The item to which the price was added to
    • getType

      ShopPriceType getType()
      Prices can vary from their type. Meaning that one takes an item from the player while something else does something different
      Returns:
      The type of this price
    • getDisplayName

      String getDisplayName(@Nullable @Nullable CommandSender sender)
      Returns the name of the price (e.g. "Iron", "Diamond") in the language of the sender
      Parameters:
      sender - The language of him. Uses the default language when passing null
      Returns:
      The display name
    • getDisplayName

      default String getDisplayName()
      Returns the name of the price (e.g. "Command", "Iron", "Dirt") in the default language
      Returns:
      The display name
    • getDisplayName

      String getDisplayName(@Nullable @Nullable CommandSender sender, int amount)
      Returns the name of the price (e.g. "Iron", "Diamond") in the language of the sender
      Parameters:
      sender - The language of him. Uses the default language when passing null
      amount - the amount of material required
      Returns:
      The display name
    • getDisplayName

      default String getDisplayName(int amount)
      Returns the name of the price (e.g. "Command", "Iron", "Dirt") in the default language
      Parameters:
      amount - the amount of material required
      Returns:
      The display name
    • getDisplayItem

      ItemStack getDisplayItem(Player player)
      Returns the item that'll be displayed in (shop) GUIs
      Parameters:
      player - Item might vary per player
      Returns:
      The ItemStack that can be used for displaying in GUIs
    • getAmount

      int getAmount(Player player)
      Returns the amount that will be taken
      Parameters:
      player - Might vary per player
      Returns:
      The amount
    • getGeneralAmount

      int getGeneralAmount()
      Returns the general amount that will be taken
      Returns:
      The amount
    • setGeneralAmount

      boolean setGeneralAmount(int amount)
      Set the general amount that will be taken from the player.
      Not any product type does support this operation, those who don't support it will return false
      Parameters:
      amount - The new amount
      Returns:
      If this operation is being supported by the type
    • getHoldingAmount

      int getHoldingAmount(Player player, @Nullable @Nullable ItemStack[] inv)
      Returns the amount of instances the player is holding (in his inventory)

      Example: If the player has 9 iron and the price for him is 2 iron, then this method returns 4.

      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 amount he's holding
    • getHoldingAmount

      default int getHoldingAmount(Player player)
      Returns the amount of instances the player is holding (in his inventory)

      Example: If the player has 9 iron and the price for him is 2 iron, then this method returns 4.

      Parameters:
      player - The player we want to check
      Returns:
      The amount he's holding
    • getMissingAmount

      int getMissingAmount(Player player, @Nullable @Nullable ItemStack[] inv)
      Returns the amount of instances (i.a. item) the player is missing to pay the price

      Example: If the player has 2 iron and the price for him is 5 iron, then this method returns 3.

      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 amount he's missing
    • getMissingAmount

      default int getMissingAmount(Player player)
      Returns the amount of instances (i.a. item) the player is missing to pay the price

      Example: If the player has 2 iron and the price for him is 5 iron, then this method returns 3.

      Parameters:
      player - The player we want to check
      Returns:
      The amount he's missing
    • take

      boolean take(Player player, int multiplier, @Nullable @Nullable ItemStack[] inv)
      Takes the price from the player

      Might fail (returns false) when the player does not hold enough.

      Parameters:
      player - The target player
      multiplier - This multiplied with getAmount(Player) equals the final amount that will be taken
      inv - The theoretical inventory from which it shall be taken. null if it shall use the players inventory
      Returns:
      True if everything has been taken from him, otherwise false
    • take

      default boolean take(Player player, int multiplier)
      Takes the price from the player

      Might fail (returns false) when the player does not hold enough.

      Parameters:
      player - The target player
      multiplier - This multiplied with getAmount(Player) equals the final amount that will be taken
      Returns:
      True if everything has been taken from him, otherwise false