Class CurrencyRewardEvent

java.lang.Object
org.bukkit.event.Event
dev.itsharshxd.zentrix.api.events.ZentrixEvent
dev.itsharshxd.zentrix.api.events.currency.CurrencyRewardEvent
All Implemented Interfaces:
org.bukkit.event.Cancellable

public final class CurrencyRewardEvent extends ZentrixEvent implements org.bukkit.event.Cancellable
Called before Zentrix pays one of its built-in rewards, such as a kill, a placement or a class ability trigger, configured in gameplay/economy.yml.

This is the reward policy: change the amount, or cancel to withhold the reward without affecting anything else the trigger does - a cancelled kill reward still counts the kill. It fires once per reward, after Zentrix decided the player earns it and before the balance change is queued; CurrencyChangeEvent still fires for the resulting change. A reward whose amount is zero after this event is not paid and sends no message.

The amount already includes Zentrix's reward multiplier, such as the player's rewards.bonus perk or a zentrix.multiplier.* permission. getBaseAmount() and getMultiplier() expose it, so an addon's boost can replace or build on it deliberately instead of stacking on it unnoticed.

Fired on the main thread, and only while a listener is registered.

Since:
1.8.0
  • Nested Class Summary

    Nested classes/interfaces inherited from class org.bukkit.event.Event

    org.bukkit.event.Event.Result
  • Constructor Summary

    Constructors
    Constructor
    Description
    CurrencyRewardEvent(@NotNull org.bukkit.entity.Player player, @NotNull CurrencyEventType rewardType, @Nullable ZentrixGame game, double amount)
     
    CurrencyRewardEvent(@NotNull org.bukkit.entity.Player player, @NotNull CurrencyEventType rewardType, @Nullable ZentrixGame game, double baseAmount, double multiplier)
    Constructs a reward whose amount already includes Zentrix's reward multiplier.
  • Method Summary

    Modifier and Type
    Method
    Description
    double
    The amount that will be paid; negative for a penalty.
    double
    The amount before Zentrix's reward multiplier: the configured reward, or the amount an earlier, more specific event such as PlayerKillEvent settled on.
    double
    How much the reward multiplier added to the base amount, before any listener: getConfiguredAmount() - getBaseAmount().
    double
    The amount Zentrix decided before any listener, after its reward multiplier: the configured reward, or the amount an earlier, more specific event such as PlayerKillEvent settled on, raised by the multiplier.
    The match the reward was earned in, when the player is in one.
    static @NotNull org.bukkit.event.HandlerList
     
    @NotNull org.bukkit.event.HandlerList
    Gets the handler list for this event.
    double
    The reward multiplier Zentrix already applied, such as the player's rewards.bonus perk or a zentrix.multiplier.* permission.
    @NotNull org.bukkit.entity.Player
    The player being rewarded.
    Which built-in reward this is.
    boolean
     
    void
    setAmount(double amount)
    Changes the amount that will be paid.
    void
    setCancelled(boolean cancelled)
     

    Methods inherited from class org.bukkit.event.Event

    callEvent, getEventName, isAsynchronous

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • CurrencyRewardEvent

      public CurrencyRewardEvent(@NotNull @NotNull org.bukkit.entity.Player player, @NotNull @NotNull CurrencyEventType rewardType, @Nullable @Nullable ZentrixGame game, double amount)
    • CurrencyRewardEvent

      public CurrencyRewardEvent(@NotNull @NotNull org.bukkit.entity.Player player, @NotNull @NotNull CurrencyEventType rewardType, @Nullable @Nullable ZentrixGame game, double baseAmount, double multiplier)
      Constructs a reward whose amount already includes Zentrix's reward multiplier.
      Parameters:
      baseAmount - the amount before the multiplier
      multiplier - the multiplier Zentrix applied, such as the player's rewards.bonus perk; 1.0 for none
      Since:
      1.13.0
  • Method Details

    • getPlayer

      @NotNull public @NotNull org.bukkit.entity.Player getPlayer()
      The player being rewarded.
    • getRewardType

      @NotNull public @NotNull CurrencyEventType getRewardType()
      Which built-in reward this is.
    • getGame

      @NotNull public @NotNull Optional<ZentrixGame> getGame()
      The match the reward was earned in, when the player is in one.
    • getConfiguredAmount

      public double getConfiguredAmount()
      The amount Zentrix decided before any listener, after its reward multiplier: the configured reward, or the amount an earlier, more specific event such as PlayerKillEvent settled on, raised by the multiplier.
    • getBaseAmount

      public double getBaseAmount()
      The amount before Zentrix's reward multiplier: the configured reward, or the amount an earlier, more specific event such as PlayerKillEvent settled on.
      Since:
      1.13.0
    • getMultiplier

      public double getMultiplier()
      The reward multiplier Zentrix already applied, such as the player's rewards.bonus perk or a zentrix.multiplier.* permission. The amount includes it: an addon that boosts the reward can compare against it rather than stack on it unnoticed.
      Returns:
      the multiplier; 1.0 when none
      Since:
      1.13.0
    • getBonusAmount

      public double getBonusAmount()
      How much the reward multiplier added to the base amount, before any listener: getConfiguredAmount() - getBaseAmount().
      Returns:
      the bonus; 0 when no multiplier applied
      Since:
      1.13.0
    • getAmount

      public double getAmount()
      The amount that will be paid; negative for a penalty.
    • setAmount

      public void setAmount(double amount)
      Changes the amount that will be paid.
      Parameters:
      amount - the amount; negative for a penalty, zero to pay nothing
      Throws:
      IllegalArgumentException - if the amount is not a finite number
    • isCancelled

      public boolean isCancelled()
      Specified by:
      isCancelled in interface org.bukkit.event.Cancellable
    • setCancelled

      public void setCancelled(boolean cancelled)
      Specified by:
      setCancelled in interface org.bukkit.event.Cancellable
    • getHandlers

      @NotNull public @NotNull org.bukkit.event.HandlerList getHandlers()
      Description copied from class: ZentrixEvent
      Gets the handler list for this event.
      Overrides:
      getHandlers in class ZentrixEvent
      Returns:
      The handler list
    • getHandlerList

      @NotNull public static @NotNull org.bukkit.event.HandlerList getHandlerList()