Class PetLevelEvent

Direct Known Subclasses:
PetLevelDownEvent, PetLevelUpEvent

public class PetLevelEvent extends PetEvent
Common parent for level-transition events. Not directly fired — listeners should subscribe to the concrete subclasses PetLevelUpEvent and PetLevelDownEvent, which fire from PetExperience#updateExp on real level transitions and carry the previous level via fromLevel().

Not cancellable: the level change has already been applied when the subclass events fire. Cancel the upstream PetExpEvent to suppress the cascade.

Quiet flag: isQuiet() mirrors the originating PetExpEvent's quiet preference, propagated through the experience updater.

  • Constructor Details

    • PetLevelEvent

      @Deprecated(since="4.1.0", forRemoval=true) public PetLevelEvent(Pet pet, int level)
      Deprecated, for removal: This API element is subject to removal in a future version.
      nothing in MyPet calls this and it silently forces isQuiet() to true; use PetLevelEvent(Pet, int, boolean) and state the quiet flag
      Creates a quiet level event.
      Parameters:
      pet - the pet whose level changed
      level - the level it now holds
    • PetLevelEvent

      public PetLevelEvent(Pet pet, int level, boolean beQuiet)
      Creates a level event.
      Parameters:
      pet - the pet whose level changed
      level - the level it now holds
      beQuiet - true to suppress the usual player-facing messaging
  • Method Details

    • getHandlerList

      public static HandlerList getHandlerList()
      Returns the handler list for this event type.
      Returns:
      the shared HandlerList every PetLevelEvent is dispatched through
    • isQuiet

      public boolean isQuiet()
      Returns whether the originating PetExpEvent asked for the change to be silent.
      Returns:
      true if player-facing messaging should be suppressed
    • getHandlers

      public @NonNull HandlerList getHandlers()
      Specified by:
      getHandlers in class Event
    • getPet

      public Pet getPet()
      The pet whose level changed.
      Specified by:
      getPet in class PetEvent
      Returns:
      the pet whose level changed
    • getLevel

      public int getLevel()
      The level the pet holds after the transition.
      Returns:
      the level it now holds