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

public class PlayerBuyInShopEvent extends PlayerEvent implements ArenaEvent
Gets called when a player is buying an item from the shop
  • Constructor Details

  • Method Details

    • getArena

      @Nullable public @Nullable Arena getArena()
      Returns the arena in which the player is playing.
      Specified by:
      getArena in interface ArenaEvent
      Returns:
      The player's arena. Can be null if the player is using the shop outside of an arena.
    • getItem

      public ShopItem getItem()
      Returns the item that the player wants to buy.
      Returns:
      The item that he's trying to buy
    • getClonedItem

      @Nullable public @Nullable ShopItem getClonedItem()
      Get the cloned item that was used within PlayerOpenShopEvent.getClonedPage().
      Returns:
      If known, the cloned item that was used to render the shop. Otherwise null.
    • getOpenCause

      public ShopOpenCause 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

      @Nullable public @Nullable Integer 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

      public List<PlayerBuyInShopEvent.Problem> getProblems()
      Returns the problems that are preventing the item from being bought
      Returns:
      The problems
    • addProblem

      public boolean addProblem(PlayerBuyInShopEvent.Problem problem)
      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

      public boolean addProblem(PlayerBuyInShopEvent.DefaultProblem problem)
      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

      public boolean removeProblem(PlayerBuyInShopEvent.Problem problem)
      Removes a problem.
      Parameters:
      problem - The problem
      Returns:
      If it has been removed or not
    • removeProblem

      public boolean removeProblem(PlayerBuyInShopEvent.DefaultProblem problem)
      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

      public HandlerList getHandlers()
      Specified by:
      getHandlers in class Event
    • getHandlerList

      public static HandlerList getHandlerList()