Class PetExpEvent
- All Implemented Interfaces:
Cancellable
PetExperience#updateExp flow that backs
addExp, removeExp, and the percent-add helpers.
Fires from PetExperience immediately before the exp delta is
applied and the level is recomputed.
Cancellable: cancellation skips the exp change entirely —
updateExp returns 0 and the level recomputation does not
happen, so no follow-up PetLevelUpEvent or PetLevelDownEvent
is dispatched.
Mutable delta: setExp(double) adjusts the value to be
applied — useful for multipliers (XP-boost potions) or caps. The signed
value reflects the direction (positive for gain, negative for loss); the
post-clamp result is also bounded by 0..maxExp on the pet side.
Quiet flag: isQuiet() mirrors the caller's quiet
preference and is propagated forward to PetLevelUpEvent /
PetLevelDownEvent if the level changes.
Pet state: live pet (experience changes only happen on the runtime).
-
Nested Class Summary
Nested classes/interfaces inherited from class org.bukkit.event.Event
Event.Result -
Constructor Summary
ConstructorsConstructorDescriptionPetExpEvent(Pet pet, double exp) Creates the event for a non-quiet experience change.PetExpEvent(Pet pet, double exp, boolean quiet) Creates the event for an experience change. -
Method Summary
Modifier and TypeMethodDescriptiondoublegetExp()The signed experience delta about to be applied -- positive for a gain, negative for a loss.static HandlerListReturns the handler list for this event type.getPet()The pet whose experience is about to change.booleanisQuiet()Whether the caller asked for the change to be silent.voidsetExp(double exp) The signed experience delta about to be applied -- positive for a gain, negative for a loss.Methods inherited from class de.Keyle.MyPet.api.event.CancellablePetEvent
isCancelled, setCancelledMethods inherited from class org.bukkit.event.Event
callEvent, getEventName, isAsynchronous
-
Constructor Details
-
PetExpEvent
Creates the event for an experience change.- Parameters:
pet- the pet gaining or losing experienceexp- the signed experience deltaquiet-trueto suppress the usual player-facing messaging
-
PetExpEvent
Creates the event for a non-quiet experience change.- Parameters:
pet- the pet gaining or losing experienceexp- the signed experience delta
-
-
Method Details
-
getHandlerList
Returns the handler list for this event type.- Returns:
- the shared
HandlerListeveryPetExpEventis dispatched through
-
getHandlers
- Specified by:
getHandlersin classEvent
-
getPet
The pet whose experience is about to change. -
isQuiet
public boolean isQuiet()Whether the caller asked for the change to be silent. Propagated toPetLevelUpEvent/PetLevelDownEventif the level moves.- Returns:
trueif player-facing messaging is suppressed
-
getExp
public double getExp()The signed experience delta about to be applied -- positive for a gain, negative for a loss. Listeners may rewrite it to apply multipliers or caps; the pet clamps the result to its own0..maxExprange.- Returns:
- the signed experience delta about to be applied
-
setExp
public void setExp(double exp) The signed experience delta about to be applied -- positive for a gain, negative for a loss. Listeners may rewrite it to apply multipliers or caps; the pet clamps the result to its own0..maxExprange.- Parameters:
exp- the value to set
-