Package de.Keyle.MyPet.api.event
Class PetFeedEvent
java.lang.Object
org.bukkit.event.Event
de.Keyle.MyPet.api.event.PetEvent
de.Keyle.MyPet.api.event.CancellablePetEvent
de.Keyle.MyPet.api.event.PetInteractEvent
de.Keyle.MyPet.api.event.PetFeedEvent
- All Implemented Interfaces:
Cancellable
Fired when an owner right-clicks a pet with a food
ItemStack.
Subclass of PetInteractEvent — extends the right-click hook with
food-specific fields.
Fires from Pet#mobInteract on player-pet right-click and from
the self-feed branch when the pet auto-eats a held item.
Cancellable (inherited): cancellation suppresses the feed action entirely — no saturation gain, no item consumption, no heal.
Mutable fields:
setSaturation(double)adjusts the saturation gained from this feed; default is the food's vanilla saturation.setResult(Result)chooses the visual / audio reaction:PetFeedEvent.Result.HEAL(heart particles + heal animation),PetFeedEvent.Result.EAT(eating particles + munch sound),PetFeedEvent.Result.SELF_FEED(no player interaction; pet ate from its own backpack or AI behavior).
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enumThe visual and audible reaction a feed produces. -
Constructor Summary
ConstructorsConstructorDescriptionPetFeedEvent(Pet pet, ItemStack item, double saturation, PetFeedEvent.Result result) Creates the event for a pet about to be fed. -
Method Summary
Modifier and TypeMethodDescriptionstatic HandlerListReturns the handler list for this event type.The reaction the pet plays for this feed.doubleThe saturation this feed restores.voidsetResult(PetFeedEvent.Result result) The reaction the pet plays for this feed.voidsetSaturation(double saturation) The saturation this feed restores.Methods inherited from class de.Keyle.MyPet.api.event.PetInteractEvent
getItem, getPetMethods inherited from class de.Keyle.MyPet.api.event.CancellablePetEvent
isCancelled, setCancelledMethods inherited from class org.bukkit.event.Event
callEvent, getEventName, isAsynchronous
-
Constructor Details
-
PetFeedEvent
Creates the event for a pet about to be fed.- Parameters:
pet- the pet being feditem- the food itemsaturation- the saturation the feed restoresresult- the reaction to play
-
-
Method Details
-
getHandlerList
Returns the handler list for this event type.- Returns:
- the shared
HandlerListeveryPetFeedEventis dispatched through
-
getHandlers
- Overrides:
getHandlersin classPetInteractEvent
-
setSaturation
public void setSaturation(double saturation) The saturation this feed restores. Defaults to the food item's vanilla saturation value.- Parameters:
saturation- the value to set
-
setResult
The reaction the pet plays for this feed.- Parameters:
result- the value to set
-
getSaturation
public double getSaturation()The saturation this feed restores. Defaults to the food item's vanilla saturation value.- Returns:
- the saturation this feed restores
-
getResult
The reaction the pet plays for this feed.- Returns:
- the reaction the pet plays
-