Package de.Keyle.MyPet.api.event
Class PetEvent
java.lang.Object
org.bukkit.event.Event
de.Keyle.MyPet.api.event.PetEvent
- Direct Known Subclasses:
CancellablePetEvent,PetActivatedEvent,PetCreateEvent,PetLevelEvent,PetLoadEvent,PetRemoveEvent,PetSaveEvent,PetSelectSkilltreeEvent,PetStatusEvent
Common base of every MyPet event that concerns one specific pet. It gives
addon code a single type to accept, store or test with
instanceof
when it only needs to know which pet an event is about and who owns it, and
it holds the owner and player accessors that every pet event shares.
Listening: this class is abstract and, like Bukkit's own
BlockEvent or PlayerEvent, has no handler list of its own, so
it cannot be passed to an @EventHandler method directly. Register
against a concrete event such as PetCallEvent; use PetEvent
for helper methods and type checks inside the handler.
Pet type: getPet() is declared as the widest type,
StoredPet. Events that only fire for a live pet narrow the return
type to Pet in their own override, so existing listeners keep
compiling and linking unchanged.
Events that carry a pet but are not cancellable extend this class
directly; the cancellable ones extend CancellablePetEvent.
-
Nested Class Summary
Nested classes/interfaces inherited from class org.bukkit.event.Event
Event.Result -
Constructor Summary
Constructors -
Method Summary
Methods inherited from class org.bukkit.event.Event
callEvent, getEventName, getHandlers, isAsynchronous
-
Constructor Details
-
PetEvent
protected PetEvent()Creates a synchronous pet event.
-
-
Method Details
-
getPet
Returns the pet this event concerns.- Returns:
- the pet; concrete events narrow this to
Petwhen the pet is guaranteed to be live
-
getOwner
Returns the owner of the pet this event concerns.- Returns:
- the pet's owner
-
getPlayer
Returns the Bukkit player behind the pet's owner.- Returns:
- the owner's
Player, valid only whileMyPetPlayer.isOnline()istrue
-