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
Nested ClassesModifier and TypeClassDescriptionstatic enumDefault problems used and provided by the pluginstatic classNested 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
ConstructorsConstructorDescriptionPlayerBuyInShopEvent(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 TypeMethodDescriptionbooleanAdd a problem that will prevent the item from being bought.booleanaddProblem(PlayerBuyInShopEvent.Problem problem) Add a problem that will prevent the item from being bought.@Nullable ArenagetArena()Returns the arena in which the player is playing.@Nullable ShopItemGet the cloned item that was used withinPlayerOpenShopEvent.getClonedPage().static HandlerListgetItem()Returns the item that the player wants to buy.intReturns 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 IntegerPlayer clicked on a specific number on his keyboard while buying.booleanReturns whether or not the player will receive the products of the item.booleanReturns whether or not the player shift-clicked while buying the item and by that tries to buy a whole stack.booleanReturns whether or not the it'll take the payments from the player.intRemoves all problems and makes it buyable by that.booleanRemoves a problem.booleanRemoves a problem.voidsetGivingProducts(boolean giveProducts) Define whether or not if he'll get products.voidsetMultiplier(int multiplier) Set how often/many items he should receive the item.voidsetTakingPayments(boolean takePayments) Define whether or not the payments will be taken from the player.Methods inherited from class org.bukkit.event.player.PlayerEvent
getPlayerMethods 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:
getArenain interfaceArenaEvent- Returns:
- The player's arena. Can be
nullif 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
nullif 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:
falseif 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:
falseif 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:
getHandlersin classEvent
-
getHandlerList
-