Class PlayerStatisticChangeEvent<T>

java.lang.Object
org.bukkit.event.Event
com.github.darksoulq.abyssallib.server.event.custom.entity.PlayerStatisticChangeEvent<T>
Type Parameters:
T - The data type of the statistic value being changed.
All Implemented Interfaces:
org.bukkit.event.Cancellable

public class PlayerStatisticChangeEvent<T> extends org.bukkit.event.Event implements org.bukkit.event.Cancellable
An event called when a player's persistent statistic value is changed. This event is Cancellable, allowing listeners to prevent the change or modify the new value before it is saved to the database.
  • Nested Class Summary

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

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

    Constructors
    Constructor
    Description
    PlayerStatisticChangeEvent(@NotNull org.bukkit.entity.Player player, @NotNull Statistic statistic, T oldValue, T newValue)
    Constructs a new PlayerStatisticChangeEvent.
  • Method Summary

    Modifier and Type
    Method
    Description
    static org.bukkit.event.HandlerList
    Provides a static method to retrieve the handler list, required by Bukkit.
    @NotNull org.bukkit.event.HandlerList
    Retrieves the list of handlers listening to this event instance.
    Retrieves the proposed new value for the statistic.
    Retrieves the value of the statistic prior to this change event.
    @NotNull org.bukkit.entity.Player
    Retrieves the player involved in this statistic change.
    @NotNull Statistic
    Retrieves the specific statistic container that is being updated.
    boolean
    Checks if the statistic change has been cancelled.
    void
    setCancelled(boolean v)
    Sets the cancellation state of the event.
    void
    setNewValue(T newValue)
    Overrides the proposed new value with a different one.

    Methods inherited from class org.bukkit.event.Event

    callEvent, getEventName, isAsynchronous

    Methods inherited from class Object

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

    • PlayerStatisticChangeEvent

      public PlayerStatisticChangeEvent(@NotNull @NotNull org.bukkit.entity.Player player, @NotNull @NotNull Statistic statistic, T oldValue, T newValue)
      Constructs a new PlayerStatisticChangeEvent.
      Parameters:
      player - The Player instance whose data is changing.
      statistic - The Statistic instance involved in the change.
      oldValue - The value prior to the update.
      newValue - The value proposed for the update.
  • Method Details

    • getPlayer

      @NotNull public @NotNull org.bukkit.entity.Player getPlayer()
      Retrieves the player involved in this statistic change.
      Returns:
      The Player instance.
    • getStatistic

      @NotNull public @NotNull Statistic getStatistic()
      Retrieves the specific statistic container that is being updated.
      Returns:
      The Statistic definition and container.
    • getOldValue

      public T getOldValue()
      Retrieves the value of the statistic prior to this change event.
      Returns:
      The old value of type T.
    • getNewValue

      public T getNewValue()
      Retrieves the proposed new value for the statistic.
      Returns:
      The proposed new value of type T.
    • setNewValue

      public void setNewValue(T newValue)
      Overrides the proposed new value with a different one.
      Parameters:
      newValue - The new value to be assigned to the player's statistic.
    • isCancelled

      public boolean isCancelled()
      Checks if the statistic change has been cancelled.
      Specified by:
      isCancelled in interface org.bukkit.event.Cancellable
      Returns:
      True if the change is prevented, false otherwise.
    • setCancelled

      public void setCancelled(boolean v)
      Sets the cancellation state of the event.
      Specified by:
      setCancelled in interface org.bukkit.event.Cancellable
      Parameters:
      v - True to cancel the change, false to allow it.
    • getHandlers

      @NotNull public @NotNull org.bukkit.event.HandlerList getHandlers()
      Retrieves the list of handlers listening to this event instance.
      Specified by:
      getHandlers in class org.bukkit.event.Event
      Returns:
      The HandlerList for this event.
    • getHandlerList

      public static org.bukkit.event.HandlerList getHandlerList()
      Provides a static method to retrieve the handler list, required by Bukkit.
      Returns:
      The static HandlerList for this event type.