Class EntityAttributeChangeEvent<T extends Number>

java.lang.Object
org.bukkit.event.Event
com.github.darksoulq.abyssallib.server.event.custom.entity.EntityAttributeChangeEvent<T>
Type Parameters:
T - The numeric type of the attribute being modified.
All Implemented Interfaces:
org.bukkit.event.Cancellable

public class EntityAttributeChangeEvent<T extends Number> extends org.bukkit.event.Event implements org.bukkit.event.Cancellable
An event called when an entity's base attribute value is changed. This event is Cancellable, allowing listeners to prevent the change or modify the new value before it is persisted 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
    EntityAttributeChangeEvent(@NotNull org.bukkit.entity.Entity entity, @NotNull Attribute<T> attribute, T oldValue, T newValue)
    Constructs a new EntityAttributeChangeEvent.
  • Method Summary

    Modifier and Type
    Method
    Description
    @NotNull Attribute<T>
    Retrieves the specific attribute that is being modified.
    @NotNull org.bukkit.entity.Entity
    Retrieves the entity involved in this attribute change.
    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 attribute.
    Retrieves the value of the attribute prior to this change event.
    boolean
    Checks if the attribute 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

    • EntityAttributeChangeEvent

      public EntityAttributeChangeEvent(@NotNull @NotNull org.bukkit.entity.Entity entity, @NotNull @NotNull Attribute<T> attribute, T oldValue, T newValue)
      Constructs a new EntityAttributeChangeEvent.
      Parameters:
      entity - The Entity instance whose attribute is changing.
      attribute - The Attribute definition being updated.
      oldValue - The previous base value.
      newValue - The proposed new base value.
  • Method Details

    • getEntity

      @NotNull public @NotNull org.bukkit.entity.Entity getEntity()
      Retrieves the entity involved in this attribute change.
      Returns:
      The Entity instance.
    • getAttribute

      @NotNull public @NotNull Attribute<T> getAttribute()
      Retrieves the specific attribute that is being modified.
      Returns:
      The Attribute definition.
    • getOldValue

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

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

      public void setNewValue(T newValue)
      Overrides the proposed new value with a different one.
      Parameters:
      newValue - The new base value to apply to the entity.
    • isCancelled

      public boolean isCancelled()
      Checks if the attribute change has been cancelled.
      Specified by:
      isCancelled in interface org.bukkit.event.Cancellable
      Returns:
      True if the event is cancelled, preventing the value update.
    • 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 to proceed.
    • 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.