Interface ShopItem
- All Superinterfaces:
Cloneable
-
Method Summary
Modifier and TypeMethodDescriptionaddPriceItem
(ItemStack price, int amount) Adds an ItemStack price to this instance.addPriceSpawner
(DropType price, int amount) Adds a Spawner price to this instance.addProductCommand
(String command, boolean executeAsConsole) Adds a product that executes a command when this item is being bought.addProductItem
(ItemStack item, int amount) Adds a product that gives the player an ItemStack when this item is being bought.addProductSpawner
(DropType dropType, int amount) Adds a product that gives the player a spawner drops when this item is being bought.addProductSpecialItem
(SpecialItem specialItem, int amount) Adds a product that gives the player a SpecialItem when this item is being bought.Make the player buy the item.default int
calcPurchasableQuantity
(Player player) Returns the amount of how often the player could purchase this item in the invoked momentint
calcPurchasableQuantity
(Player player, @Nullable ItemStack[] inv) Returns the amount of how often the player could purchase this item in the invoked momentclone()
Returns a clone of this instance.@Nullable BuyGroup
Returns the buy-group of the item.int
Returns the buy-group level of this item.@Nullable String
Get the required buy permission id for shop item purchase.int
Get the max amount that'll be multiplied when shift-clicking the item in the shop.@Nullable String
Returns the unformatted description as it is written in the configs.default @Nullable String
Returns the formatted description of the item in the default language.@Nullable String
getDescription
(@Nullable CommandSender sender) Returns the formatted description in the language of the sender.default String
Returns the formatted name of the item in the default language.getDisplayName
(@Nullable CommandSender sender) Returns the formatted name in the language of the sender.@Nullable Integer
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 thatgetIcon()
Returns the icon that will be shown in the shop GUI.getId()
Get the id of this item.getName()
Returns its unformatted name as it is in the config file.Returns the original "non-cloned" instance.getPage()
Returns the page in which the item is inside.Returns the prices that will be taken from the player when he's trying to buy the item.List
<? extends ShopProduct> Returns the products that will be given to the buyer.@Nullable ArenaConditionGroup
The ArenaConditionGroup that controls what arenas this ShopItem is visible in.boolean
Returns if the item is a member of a buy-group or not.boolean
hasBuyPermission
(Player player) Weather or not a player has permission to buy this item.boolean
isClone()
Checks whether this instance is a clone (as if it has been cloned usingclone()
).boolean
Get whether the id of this item has been auto-generated or not.boolean
Returns whether the item will be kept when the player dies.boolean
Returns whether the item can be only bought once.boolean
removePrice
(ShopPrice price) Removes a price instance from this item.boolean
removeProduct
(ShopProduct product) Removes a product instance from this item.void
setBuyGroup
(@Nullable BuyGroup buyGroup) Set the new buy-group of this item or remove it from an existing one.void
setBuyGroupLevel
(int level) Set the buy-group level of this item.void
setBuyPermissionId
(@Nullable String permissionId) Set a required buy permission for players.void
setCapsMultiply
(int capsMultiply) Set the max amount that'll be multiplied when shift-clicking the item in the shop.void
setConfigDescription
(@Nullable String description) Change the description of the item.void
setForceSlot
(@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 thatvoid
Set the icon that shall be shown in the shop GUI.void
setKeptOnDeath
(boolean keepOnDeath) Define whether the item shall be kept on death.void
Changes the name of this ShopItem.void
setOneTimePurchase
(boolean oneTimePurchase) Define whether the item can be only bought once.void
setRestriction
(@Nullable ArenaConditionGroup restriction) Lets you restrict this ShopItem, so only be available in certain arenas
-
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 returntrue
.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, otherwisefalse
- See Also:
-
getName
String getName()Returns its unformatted name as it is in the config file.- Returns:
- The name of the item
-
setName
Changes the name of this ShopItem.- Parameters:
name
- the new name of this item
-
getDisplayName
Returns the formatted name of the item in the default language.- Returns:
- The display name in the default language
-
getDisplayName
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
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
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
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
Change the description of the item.- Parameters:
description
- The new unformatted description. May benull
-
getPage
ShopPage getPage()Returns the page in which the item is inside.- Returns:
- The page in which the item has been added
-
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
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 purchaseamount
- The amount of material required for the purchase- Returns:
- The price created and applied to the item
-
addPriceSpawner
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 purchaseamount
- The amount of material required for the purchase- Returns:
- The price created and applied to the item
-
removePrice
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. Otherwisefalse
-
addProductCommand
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 purchaseexecuteAsConsole
- 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
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 purchaseamount
- The amount of items the player will receive- Returns:
- The product created and applied to the item
-
addProductSpawner
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 purchaseamount
- The amount of items the player will receive- Returns:
- The product created and applied to the item
-
addProductSpecialItem
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 itemamount
- The amount of items the player will receive- Returns:
- The product created and applied to the item
-
removeProduct
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. Otherwisefalse
-
getIcon
ItemStack getIcon()Returns the icon that will be shown in the shop GUI.- Returns:
- The icon
-
setIcon
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
Returns the buy-group of the item. Might benull
if it isn't in any.- Returns:
- The buy-group of this item
-
setBuyGroup
Set the new buy-group of this item or remove it from an existing one.- Parameters:
buyGroup
- Its new buy-group, ornull
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, otherwisefalse
-
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
Weather or not a player has permission to buy this item.- Parameters:
player
- The player we want to check
-
setBuyPermissionId
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
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
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
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
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
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
Returns the amount of how often the player could purchase this item in the invoked moment- Parameters:
player
- The player we want to checkinv
- 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
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
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 toisShiftClick
- 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 usingclone()
).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:
-