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
ConstructorsConstructorDescriptionPlayerStatisticChangeEvent(@NotNull org.bukkit.entity.Player player, @NotNull Statistic statistic, T oldValue, T newValue) Constructs a new PlayerStatisticChangeEvent. -
Method Summary
Modifier and TypeMethodDescriptionstatic org.bukkit.event.HandlerListProvides a static method to retrieve the handler list, required by Bukkit.@NotNull org.bukkit.event.HandlerListRetrieves 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.PlayerRetrieves the player involved in this statistic change.@NotNull StatisticRetrieves the specific statistic container that is being updated.booleanChecks if the statistic change has been cancelled.voidsetCancelled(boolean v) Sets the cancellation state of the event.voidsetNewValue(T newValue) Overrides the proposed new value with a different one.Methods inherited from class org.bukkit.event.Event
callEvent, getEventName, isAsynchronous
-
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- ThePlayerinstance whose data is changing.statistic- TheStatisticinstance 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
Playerinstance.
-
getStatistic
-
getOldValue
Retrieves the value of the statistic prior to this change event.- Returns:
- The old value of type
T.
-
getNewValue
Retrieves the proposed new value for the statistic.- Returns:
- The proposed new value of type
T.
-
setNewValue
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:
isCancelledin interfaceorg.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:
setCancelledin interfaceorg.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:
getHandlersin classorg.bukkit.event.Event- Returns:
- The
HandlerListfor 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
HandlerListfor this event type.
-