Class EntityAttributeModifierAddEvent<T extends Number>
java.lang.Object
org.bukkit.event.Event
com.github.darksoulq.abyssallib.server.event.custom.entity.EntityAttributeModifierAddEvent<T>
- Type Parameters:
T- The numeric type of the attribute and modifier.
- All Implemented Interfaces:
org.bukkit.event.Cancellable
public class EntityAttributeModifierAddEvent<T extends Number>
extends org.bukkit.event.Event
implements org.bukkit.event.Cancellable
An event called when a new modifier is added to an entity's attribute.
This event is
Cancellable, allowing listeners to prevent the modifier
from being applied or to swap the modifier for a different one.-
Nested Class Summary
Nested classes/interfaces inherited from class org.bukkit.event.Event
org.bukkit.event.Event.Result -
Constructor Summary
ConstructorsConstructorDescriptionEntityAttributeModifierAddEvent(@NotNull org.bukkit.entity.Entity entity, @NotNull Attribute<T> attribute, @NotNull net.kyori.adventure.key.Key modifierId, @NotNull AttributeModifier<T> modifier) Constructs a new EntityAttributeModifierAddEvent. -
Method Summary
Modifier and TypeMethodDescriptionRetrieves the specific attribute that the modifier is being applied to.@NotNull org.bukkit.entity.EntityRetrieves the entity involved in this event.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.@NotNull AttributeModifier<T> Retrieves the current modifier object that is proposed to be added.@NotNull net.kyori.adventure.key.KeyRetrieves the unique identifier Key for the incoming modifier.booleanChecks if the addition of the modifier has been cancelled.voidsetCancelled(boolean v) Sets the cancellation state of the event.voidsetModifier(@NotNull AttributeModifier<T> modifier) Sets a new modifier object to be added instead of the original one.Methods inherited from class org.bukkit.event.Event
callEvent, getEventName, isAsynchronous
-
Constructor Details
-
EntityAttributeModifierAddEvent
public EntityAttributeModifierAddEvent(@NotNull @NotNull org.bukkit.entity.Entity entity, @NotNull @NotNull Attribute<T> attribute, @NotNull @NotNull net.kyori.adventure.key.Key modifierId, @NotNull @NotNull AttributeModifier<T> modifier) Constructs a new EntityAttributeModifierAddEvent.- Parameters:
entity- TheEntityreceiving the modifier.attribute- TheAttributeinstance being modified.modifierId- The uniqueKeyidentifying this specific modifier.modifier- TheAttributeModifierobject to be added.
-
-
Method Details
-
getEntity
@NotNull public @NotNull org.bukkit.entity.Entity getEntity()Retrieves the entity involved in this event.- Returns:
- The
Entityreceiving the modifier.
-
getAttribute
-
getModifierId
@NotNull public @NotNull net.kyori.adventure.key.Key getModifierId()Retrieves the unique identifier Key for the incoming modifier.- Returns:
- The modifier's
Key.
-
getModifier
Retrieves the current modifier object that is proposed to be added.- Returns:
- The
AttributeModifierinstance.
-
setModifier
Sets a new modifier object to be added instead of the original one.- Parameters:
modifier- The replacementAttributeModifierinstance.
-
isCancelled
public boolean isCancelled()Checks if the addition of the modifier has been cancelled.- Specified by:
isCancelledin interfaceorg.bukkit.event.Cancellable- Returns:
- True if the event is cancelled.
-
setCancelled
public void setCancelled(boolean v) Sets the cancellation state of the event.- Specified by:
setCancelledin interfaceorg.bukkit.event.Cancellable- Parameters:
v- True to prevent the modifier from being added.
-
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.
-