Class ClassAbilityProcEvent

java.lang.Object
org.bukkit.event.Event
dev.itsharshxd.zentrix.api.events.ZentrixEvent
dev.itsharshxd.zentrix.api.events.ZentrixGameEvent
dev.itsharshxd.zentrix.api.events.classes.ClassAbilityProcEvent
All Implemented Interfaces:
org.bukkit.event.Cancellable

public final class ClassAbilityProcEvent extends ZentrixGameEvent implements org.bukkit.event.Cancellable
Called when a built-in class ability triggers, after Zentrix decided it applies - the class, the match state and, for chance-based abilities, the roll - and before its effect happens.

Listeners can cancel the effect entirely, change its strength through setMagnitude(double) where getMagnitude() is present, replace the item it hands out where getItem() is present, or keep the ability's currency reward from being paid without touching the effect itself. A cancelled proc pays no reward either.

What each proc carries
ProcMagnitudeItemTarget
ClassAbilityProcEvent.Proc.TRUE_DAMAGEbonus damage, dealt a tick later-the victim
ClassAbilityProcEvent.Proc.BOW_SHOT_BUFF--the entity hit
ClassAbilityProcEvent.Proc.CHEST_BONUS-the bonus item added to the container-
ClassAbilityProcEvent.Proc.FALL_DAMAGE_REDUCTIONthe fraction of fall damage prevented, 0 to 1--
ClassAbilityProcEvent.Proc.EXTRA_CATCH-the extra copy of the catch dropped-
ClassAbilityProcEvent.Proc.MINERAL_DROP-the mineral dropped-
ClassAbilityProcEvent.Proc.AUTO_SMELT-the smelted result given instead of the ore's drops-

Main thread; only fired while a listener is registered.

Since:
1.8.0
  • Constructor Details

    • ClassAbilityProcEvent

      public ClassAbilityProcEvent(@NotNull @NotNull ZentrixGame game, @NotNull @NotNull org.bukkit.entity.Player player, @NotNull @NotNull ClassAbilityProcEvent.Proc proc, @Nullable @Nullable org.bukkit.entity.Entity target, double magnitude, @Nullable @Nullable org.bukkit.inventory.ItemStack item)
  • Method Details

    • getPlayer

      @NotNull public @NotNull org.bukkit.entity.Player getPlayer()
      The player whose class ability triggered.
    • getProc

      @NotNull public @NotNull ClassAbilityProcEvent.Proc getProc()
      What triggered.
    • getAbilityType

      @NotNull public @NotNull String getAbilityType()
      The ability type of the class, one of ClassAbilities.TYPES.
    • getTarget

      @NotNull public @NotNull Optional<org.bukkit.entity.Entity> getTarget()
      The entity the ability acts on, for the combat procs.
    • getMagnitude

      @NotNull public @NotNull OptionalDouble getMagnitude()
      The proc's strength, for the procs that have one.
    • setMagnitude

      public void setMagnitude(double magnitude)
      Changes the proc's strength.
      Throws:
      IllegalStateException - for a proc without a magnitude
      IllegalArgumentException - for a negative or non-finite value, or a fall damage reduction above 1
    • getItem

      @NotNull public @NotNull Optional<org.bukkit.inventory.ItemStack> getItem()
      A copy of the item the proc hands out, for the procs that hand one out.
    • setItem

      public void setItem(@NotNull @NotNull org.bukkit.inventory.ItemStack item)
      Replaces the item the proc hands out.
      Throws:
      IllegalStateException - for a proc that hands out no item
      IllegalArgumentException - for air or an empty stack
    • isRewarded

      public boolean isRewarded()
      Whether the ability's configured currency reward will be paid.
    • setRewarded

      public void setRewarded(boolean rewarded)
      Keeps the currency reward from being paid, or pays it again, without changing the effect.
    • 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: ZentrixGameEvent
      Gets the handler list for this event.
      Overrides:
      getHandlers in class ZentrixGameEvent
      Returns:
      The handler list
    • getHandlerList

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