Class PetSaveEvent


public class PetSaveEvent extends PetEvent
Fired when a pet's persisted state is being written to the repository.

Fires from numerous code paths that flush state to disk:

  • PetManager — periodic global save and the deactivation save on owner-quit.
  • CommandTrade — pet ownership transfer.
  • CommandOptionClone — admin pet clone.
  • CommandOptionCreate — admin pet creation.
  • EntityListener, PetCreaking.HeartListener — leash creation paths (alongside the corresponding PetCreateEvent).

Not cancellable: the save will proceed regardless of listeners. The pet exposed via getPet() is in the state about to be (or already being) serialized — listeners may inspect it for backup integrations or last-write metadata.

Pet state: may be live (Pet) or persisted (PersistedPet); the manager-side periodic save flushes both categories and dispatches one event per pet.

Frequency note: on a busy server the manager-side flush can fire this event hundreds of times in a tight loop. Listeners that do non-trivial work should defer it (e.g., enqueue UUID for a delayed batch) rather than blocking the save loop.

  • Constructor Details

    • PetSaveEvent

      public PetSaveEvent(StoredPet pet)
      Creates the event for a pet whose state is being written out.
      Parameters:
      pet - the pet being saved
  • Method Details

    • getHandlerList

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

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

      public StoredPet getPet()
      The pet in the exact state about to be serialized.
      Specified by:
      getPet in class PetEvent
      Returns:
      the pet being saved