Class PetDamageEvent
- All Implemented Interfaces:
Cancellable
Fires from PetSkillTriggerListener after the Damage / Bleed / Fire /
Knockback / Lightning / Stomp / Wither chain has computed final damage but
before the target's damage() call. getDamage() reflects the
already-computed total — base attack damage plus skill modifiers.
Cancellable: cancellation aborts both the damage application and any
on-hit skills queued for the strike — see PetOnHitSkillEvent, which
is dispatched per on-hit skill in the same flow.
Mutable damage: setDamage(d) clamps to max(0, d) —
negative values can't heal the target through this hook. Setting damage to
0 does NOT cancel the swing; the entity damage call still runs (which
triggers vanilla animation). To skip the strike entirely, cancel.
Pet state: live pet, with the owner online (the firing path requires the owner to be tracking the pet entity).
-
Nested Class Summary
Nested classes/interfaces inherited from class org.bukkit.event.Event
Event.Result -
Constructor Summary
ConstructorsConstructorDescriptionPetDamageEvent(Pet pet, Entity target, double damage) Creates the event for a mêlée strike that is about to land. -
Method Summary
Modifier and TypeMethodDescriptiondoubleThe damage about to be dealt: base attack damage with every on-hit skill modifier already folded in.static HandlerListReturns the handler list for this event type.getPet()The pet dealing the damage.The entity about to be damaged.voidsetDamage(double damage) Sets the damage this strike deals, clamped to zero at the low end so a negative value cannot heal the target.Methods inherited from class de.Keyle.MyPet.api.event.CancellablePetEvent
isCancelled, setCancelledMethods inherited from class org.bukkit.event.Event
callEvent, getEventName, isAsynchronous
-
Constructor Details
-
PetDamageEvent
Creates the event for a mêlée strike that is about to land.- Parameters:
pet- the attacking pettarget- the entity being struckdamage- the already-computed final damage
-
-
Method Details
-
getHandlerList
Returns the handler list for this event type.- Returns:
- the shared
HandlerListeveryPetDamageEventis dispatched through
-
setDamage
public void setDamage(double damage) Sets the damage this strike deals, clamped to zero at the low end so a negative value cannot heal the target. Setting0does not cancel the strike -- the damage call still runs and plays the vanilla hurt animation; cancel the event to skip it entirely.- Parameters:
damage- the damage to deal; values below0become0
-
getHandlers
- Specified by:
getHandlersin classEvent
-
getPet
The pet dealing the damage. -
getTarget
The entity about to be damaged.- Returns:
- the entity being struck
-
getDamage
public double getDamage()The damage about to be dealt: base attack damage with every on-hit skill modifier already folded in.- Returns:
- the damage this strike will deal
-