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
ConstructorsConstructorDescriptionEntityAttributeChangeEvent(@NotNull org.bukkit.entity.Entity entity, @NotNull Attribute<T> attribute, T oldValue, T newValue) Constructs a new EntityAttributeChangeEvent. -
Method Summary
Modifier and TypeMethodDescriptionRetrieves the specific attribute that is being modified.@NotNull org.bukkit.entity.EntityRetrieves the entity involved in this attribute change.static 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 attribute.Retrieves the value of the attribute prior to this change event.booleanChecks if the attribute 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
-
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- TheEntityinstance whose attribute is changing.attribute- TheAttributedefinition 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
Entityinstance.
-
getAttribute
-
getOldValue
Retrieves the value of the attribute prior to this change event.- Returns:
- The old base value of type
T.
-
getNewValue
Retrieves the proposed new value for the attribute.- Returns:
- The proposed new base value of type
T.
-
setNewValue
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:
isCancelledin interfaceorg.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:
setCancelledin interfaceorg.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:
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.
-