Interface ShopPage
- All Superinterfaces:
Cloneable
-
Method Summary
Modifier and TypeMethodDescriptionboolean
Adds an item to a shop page.Constructs a new ShopItem, and adds it to the ShopPage.clone()
Returns a clone of this instance.default String
Returns the formatted name of the page 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.getIcon()
Returns the icon that will be shown in the shop GUI.getItems()
Returns all the possible items that are inside the page.getName()
Returns the unformatted name.Returns the original "non-cloned" instance.@Nullable ArenaConditionGroup
The ArenaConditionGroup that controls what arenas this ShopPage is visible in.getVisiblePageItems
(@Nullable Arena arena, @Nullable Player player) Returns the items that are inside the page for a specific player.boolean
isClone()
Checks whether this instance is a clone (as if it has been cloned usingclone()
).int
removeConnectedItems
(ShopItem shopItem) Removes all ShopItems that share the original instance.boolean
removeItem
(ShopItem shopItem) Removes an item from this shop page.void
setForceSlot
(@Nullable Integer forceSlot) Define at which slot the item shall be forced at after the rendering of the shop GUI.void
Set the icon that shall be shown in the shop GUI.void
setRestriction
(@Nullable ArenaConditionGroup restriction) Lets you restrict this ShopPage, so only be available in certain arenas
-
Method Details
-
getName
String getName()Returns the unformatted name.- Returns:
- The name of the page
-
getDisplayName
Returns the formatted name of the page 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
-
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
-
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 inplayer
- The player- Returns:
- All items visible to the player
-
removeItem
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
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
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
Constructs a new ShopItem, and adds it to the ShopPage.- Parameters:
name
- The name of the item you are attempting to createicon
- The ItemStack that will be displayed as the icon in the shop- Returns:
- The new item created, and added to the shop
-
getRestriction
The ArenaConditionGroup that controls what arenas this ShopPage is visible in.- Returns:
- The condition that states the arenas this ShopPage will be available in.
null
if the ShopPage should be displayed in every arena.
-
setRestriction
Lets you restrict this ShopPage, so only be available in certain arenas- Parameters:
restriction
- The condition that states the arenas this ShopPage will be available in.null
if the ShopPage should be displayed in every arena.
-
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
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 usingclone()
).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:
-