Class PetCreateEvent


public class PetCreateEvent extends PetEvent
Fired when a brand-new pet is created and assigned to an owner — the moment a pet first enters the repository. The Source discriminates the creation pathway: PetCreateEvent.Source.LEASH (player leashes a wild mob), PetCreateEvent.Source.ADMIN_COMMAND (an admin /petadmin create-style command), PetCreateEvent.Source.PET_SHOP (PetShop integration purchase), PetCreateEvent.Source.OTHER (third-party plugins).

Fires from EntityListener (leash path), PetCreaking.HeartListener (Creaking-specific leash path), CommandOptionCreate, and the PetShop integration.

Not cancellable: the pet has already been added to the manager when this event fires. Listeners can use it to award welcome bonuses, log creation, or trigger UI flows — not to veto creation. Veto must happen earlier in the Bukkit-event chain (PlayerLeashEntityEvent for the leash sources, the command's permission check for admin / shop sources).

Pet state: getPet() is in the inactive-pets pool — the pet is persisted but not yet active. Owner is set; getPlayer() may be null only if the owner has logged off in the same tick.

Related events: PetLoadEvent fires whenever a pet is loaded from disk (creation OR subsequent activations). PetActivatedEvent fires after activation completes. PetRemoveEvent is the symmetric deletion event.

  • Constructor Details

    • PetCreateEvent

      public PetCreateEvent(StoredPet pet, PetCreateEvent.Source source)
      Creates the event for a pet that has just entered the repository.
      Parameters:
      pet - the newly created pet
      source - the pathway that created it
  • Method Details

    • getHandlerList

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

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

      public StoredPet getPet()
      The newly created pet, already present in the repository.
      Specified by:
      getPet in class PetEvent
      Returns:
      the newly created pet
    • getSource

      public PetCreateEvent.Source getSource()
      The pathway the pet was created through.
      Returns:
      the pathway that created it