Package de.Keyle.MyPet.api.event
Class PetNameEvent
java.lang.Object
org.bukkit.event.Event
de.Keyle.MyPet.api.event.PetEvent
de.Keyle.MyPet.api.event.CancellablePetEvent
de.Keyle.MyPet.api.event.PetNameEvent
- All Implemented Interfaces:
Cancellable
Fired when a pet's display name is about to change. Listeners can rewrite
the proposed name via
setNewName(String) — useful for filtering
profanity, enforcing length / character constraints, or applying server-wide
formatting rules (color codes, bracket prefixes, etc.).
Fires from Pet#setPetName for every name change source — owner
rename via /mypet name, admin rename via /petadmin name, and
any third-party setter call. The new name is applied with the value of
getNewName() at the end of the event dispatch, so listeners that
mutate it later in the chain win over earlier ones.
Cancellable: cancellation suppresses the rename entirely — the pet keeps its current name.
Pet state: live pet (name changes only happen on active pets).
Format note: the name string is in MiniMessage format —
Pet#getDisplayName deserializes it into a Component via
the sanitized MiniMessage parser. Listeners modifying the name should
preserve MiniMessage syntax.
-
Nested Class Summary
Nested classes/interfaces inherited from class org.bukkit.event.Event
Event.Result -
Constructor Summary
ConstructorsConstructorDescriptionPetNameEvent(Pet pet, String newName) Creates the event for a pending rename. -
Method Summary
Modifier and TypeMethodDescriptionstatic HandlerListReturns the handler list for this event type.The name that will be applied, in MiniMessage format.getPet()The pet being renamed.voidsetNewName(String newName) The name that will be applied, in MiniMessage format.Methods inherited from class de.Keyle.MyPet.api.event.CancellablePetEvent
isCancelled, setCancelledMethods inherited from class org.bukkit.event.Event
callEvent, getEventName, isAsynchronous
-
Constructor Details
-
PetNameEvent
Creates the event for a pending rename.- Parameters:
pet- the pet being renamednewName- the proposed name, in MiniMessage format
-
-
Method Details
-
getHandlerList
Returns the handler list for this event type.- Returns:
- the shared
HandlerListeveryPetNameEventis dispatched through
-
getHandlers
- Specified by:
getHandlersin classEvent
-
getPet
The pet being renamed. -
getNewName
The name that will be applied, in MiniMessage format. Listeners may rewrite it; the value present when dispatch ends is the one that sticks, so a later listener overrides an earlier one. Keep the MiniMessage syntax intact when modifying it.- Returns:
- the name that will be applied, in MiniMessage form
-
setNewName
The name that will be applied, in MiniMessage format. Listeners may rewrite it; the value present when dispatch ends is the one that sticks, so a later listener overrides an earlier one. Keep the MiniMessage syntax intact when modifying it.- Parameters:
newName- the value to set
-