Class PlayerBuyInShopEvent
java.lang.Object
org.bukkit.event.Event
org.bukkit.event.player.PlayerEvent
de.marcely.bedwars.api.event.player.PlayerBuyInShopEvent
- All Implemented Interfaces:
ArenaEvent
Gets called when a player is buying an item from the shop
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic enum
Default problems used and provided by the pluginstatic class
Nested classes/interfaces inherited from class org.bukkit.event.Event
Event.Result
-
Field Summary
Fields inherited from class org.bukkit.event.player.PlayerEvent
player
-
Constructor Summary
ConstructorDescriptionPlayerBuyInShopEvent
(Player player, Arena arena, ShopItem item, @Nullable ShopItem clonedItem, ShopOpenCause openCause, boolean shiftClick, @Nullable Integer targetInvSlot, int multiplier, List<PlayerBuyInShopEvent.Problem> problems, boolean giveProducts, boolean takePayments) -
Method Summary
Modifier and TypeMethodDescriptionboolean
Add a problem that will prevent the item from being bought.boolean
addProblem
(PlayerBuyInShopEvent.Problem problem) Add a problem that will prevent the item from being bought.@Nullable Arena
getArena()
Returns the arena in which the player is playing.@Nullable ShopItem
Get the cloned item that was used withinPlayerOpenShopEvent.getClonedPage()
.static HandlerList
getItem()
Returns the item that the player wants to buy.int
Returns how much it has been multiplied by shift-clicking.Returns they way the player opened the shop.Returns the problems that are preventing the item from being bought@Nullable Integer
Player clicked on a specific number on his keyboard while buying.boolean
Returns whether or not the player will receive the products of the item.boolean
Returns whether or not the player shift-clicked while buying the item and by that tries to buy a whole stack.boolean
Returns whether or not the it'll take the payments from the player.int
Removes all problems and makes it buyable by that.boolean
Removes a problem.boolean
Removes a problem.void
setGivingProducts
(boolean giveProducts) Define whether or not if he'll get products.void
setMultiplier
(int multiplier) Set how often/many items he should receive the item.void
setTakingPayments
(boolean takePayments) Define whether or not the payments will be taken from the player.Methods inherited from class org.bukkit.event.player.PlayerEvent
getPlayer
Methods inherited from class org.bukkit.event.Event
getEventName, isAsynchronous
-
Constructor Details
-
PlayerBuyInShopEvent
public PlayerBuyInShopEvent(Player player, Arena arena, ShopItem item, @Nullable @Nullable ShopItem clonedItem, ShopOpenCause openCause, boolean shiftClick, @Nullable @Nullable Integer targetInvSlot, int multiplier, List<PlayerBuyInShopEvent.Problem> problems, boolean giveProducts, boolean takePayments)
-
-
Method Details
-
getArena
Returns the arena in which the player is playing.- Specified by:
getArena
in interfaceArenaEvent
- Returns:
- The player's arena. Can be
null
if the player is using the shop outside of an arena.
-
getItem
Returns the item that the player wants to buy.- Returns:
- The item that he's trying to buy
-
getClonedItem
Get the cloned item that was used withinPlayerOpenShopEvent.getClonedPage()
.- Returns:
- If known, the cloned item that was used to render the shop. Otherwise
null
.
-
getOpenCause
Returns they way the player opened the shop.- Returns:
- The open cause
-
isShiftClick
public boolean isShiftClick()Returns whether or not the player shift-clicked while buying the item and by that tries to buy a whole stack.- Returns:
- If he shift-clicked
-
getTargetInvSlot
Player clicked on a specific number on his keyboard while buying.The given number represents the hotbar slot he wants to put the item in.
- Returns:
- The target inv slot to which the bought item shall be added to. May be
null
if that doesn't matter
-
getMultiplier
public int getMultiplier()Returns how much it has been multiplied by shift-clicking.It's always 1 by default when not shift clicked.
- Returns:
- How many he tries to buy
-
setMultiplier
public void setMultiplier(int multiplier) Set how often/many items he should receive the item.- Parameters:
multiplier
- The new multiplier value- Throws:
IllegalArgumentException
- When the new value is less than 1
-
getProblems
Returns the problems that are preventing the item from being bought- Returns:
- The problems
-
addProblem
Add a problem that will prevent the item from being bought.Act's similar as
Cancellable.setCancelled(boolean)
.- Parameters:
problem
- The problem why he can't buy it- Returns:
false
if it already has been added
-
addProblem
Add a problem that will prevent the item from being bought.Act's similar as
Cancellable.setCancelled(boolean)
.- Parameters:
problem
- The problem why he can't buy it- Returns:
false
if it already has been added
-
removeProblem
Removes a problem.- Parameters:
problem
- The problem- Returns:
- If it has been removed or not
-
removeProblem
Removes a problem.- Parameters:
problem
- The problem- Returns:
- If it has been removed or not
-
removeAllProblems
public int removeAllProblems()Removes all problems and makes it buyable by that.- Returns:
- The amount of problems that have been removed
-
isGivingProducts
public boolean isGivingProducts()Returns whether or not the player will receive the products of the item.Does not concern when there are problems as he won't receive them if there are problems anyways.
- Returns:
- If he'll get the products or not
-
setGivingProducts
public void setGivingProducts(boolean giveProducts) Define whether or not if he'll get products.Keep in mind that problems can prevent products being given to him.
- Parameters:
giveProducts
- The new value
-
isTakingPayments
public boolean isTakingPayments()Returns whether or not the it'll take the payments from the player.Does not concern when there are problems as they're preventing them from being taken anyways.
- Returns:
- If the payments will be taken or not
-
setTakingPayments
public void setTakingPayments(boolean takePayments) Define whether or not the payments will be taken from the player.Keep in mind that problems can prevent this
- Parameters:
takePayments
- The new value
-
getHandlers
- Specified by:
getHandlers
in classEvent
-
getHandlerList
-