Class CurrencyRewardEvent
- All Implemented Interfaces:
org.bukkit.event.Cancellable
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
ConstructorsConstructorDescriptionCurrencyRewardEvent(@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 TypeMethodDescriptiondoubleThe amount that will be paid; negative for a penalty.doubleThe amount before Zentrix's reward multiplier: the configured reward, or the amount an earlier, more specific event such asPlayerKillEventsettled on.doubleHow much the reward multiplier added to the base amount, before any listener:getConfiguredAmount() - getBaseAmount().doubleThe amount Zentrix decided before any listener, after its reward multiplier: the configured reward, or the amount an earlier, more specific event such asPlayerKillEventsettled on, raised by the multiplier.@NotNull Optional<ZentrixGame> getGame()The match the reward was earned in, when the player is in one.static @NotNull org.bukkit.event.HandlerList@NotNull org.bukkit.event.HandlerListGets the handler list for this event.doubleThe reward multiplier Zentrix already applied, such as the player'srewards.bonusperk or azentrix.multiplier.*permission.@NotNull org.bukkit.entity.PlayerThe player being rewarded.@NotNull CurrencyEventTypeWhich built-in reward this is.booleanvoidsetAmount(double amount) Changes the amount that will be paid.voidsetCancelled(boolean cancelled) Methods inherited from class org.bukkit.event.Event
callEvent, getEventName, isAsynchronous
-
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 multipliermultiplier- the multiplier Zentrix applied, such as the player'srewards.bonusperk; 1.0 for none- Since:
- 1.13.0
-
-
Method Details
-
getPlayer
@NotNull public @NotNull org.bukkit.entity.Player getPlayer()The player being rewarded. -
getRewardType
Which built-in reward this is. -
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 asPlayerKillEventsettled 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 asPlayerKillEventsettled on.- Since:
- 1.13.0
-
getMultiplier
public double getMultiplier()The reward multiplier Zentrix already applied, such as the player'srewards.bonusperk or azentrix.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:
isCancelledin interfaceorg.bukkit.event.Cancellable
-
setCancelled
public void setCancelled(boolean cancelled) - Specified by:
setCancelledin interfaceorg.bukkit.event.Cancellable
-
getHandlers
@NotNull public @NotNull org.bukkit.event.HandlerList getHandlers()Description copied from class:ZentrixEventGets the handler list for this event.- Overrides:
getHandlersin classZentrixEvent- Returns:
- The handler list
-
getHandlerList
@NotNull public static @NotNull org.bukkit.event.HandlerList getHandlerList()
-