Package de.Keyle.MyPet.api.player
Interface MyPetPlayer
- All Superinterfaces:
NBTStorage,Scheduler
Represents a player who owns (or may own) pets. Wraps a Bukkit
Player with MyPet-specific preferences, per-world-group pet
bindings, and extended addon data. Persisted to the repository
alongside the player's pet records.
Obtained via MyPetApi.getPlayerManager().getMyPetPlayer(Player)
or by UUID lookup. A single instance exists per online player; offline
players may be loaded on demand for repository operations.
-
Method Summary
Modifier and TypeMethodDescriptionvoidaddExtendedInfo(Plugin owner, String key, BinaryTag tag) Stores a per-addon NBT value on this player.voidbindPetToWorldGroup(WorldGroup worldGroup, UUID petUUID) Binds an ADDITIONAL pet to the world group, keeping any pets already bound.voidbindPetToWorldGroup(String worldGroup, UUID petUUID) Binds an ADDITIONAL pet to the world group, keeping any pets already bound.intReturns the minimum respawn time (seconds) the player has configured.getExtendedInfo(Plugin owner, String key) Reads a per-addon NBT value from this player's namespaced bucket.Returns the player's locale code (e.g.getName()Returns the player's current display name.default PetgetPet()Deprecated.the name says "the pet" from an era when a player could only have one out, and it silently answers for the primary now that they can have several.intDeprecated, for removal: This API element is subject to removal in a future version.usegetPets().size(), which this equalsgetPetForWorldGroup(WorldGroup worldGroup) Returns the first (primary) pet bound to the given world group, ornull.getPetForWorldGroup(String worldGroup) Returns the first (primary) pet bound to the given world group, ornull.getPets()Returns all of this player's active pets, in activation order.getPetsForWorldGroup(WorldGroup worldGroup) Returns all pets bound to the given world group, in binding order.getPetsForWorldGroup(String worldGroup) Returns all pets bound to the given world group, in binding order.Deprecated, for removal: This API element is subject to removal in a future version.a world group may hold more than one pet binding, which aBiMapcannot represent.floatReturns the volume multiplier for sounds the pet emits.Returns the underlying Bukkit player.Returns the player's primary active pet — the first one activated that is still active — ornullif none is active in the current world group.default UUIDThe UUID last passed toselectPet(java.util.UUID), ornull.Returns the player's Mojang UUID.Returns the full world-group → pet UUID bindings.getWorldGroupForPet(UUID petUUID) Returns the world group name that a pet UUID is bound to.booleanReturnstrueif the pet will auto-respawn after its timer.booleanWhether this player has any non-default custom data persisted.booleanhasPet()Returnstrueif this player has at least one active (live) pet.booleanhasPetInWorldGroup(WorldGroup worldGroup) Returnstrueif this player has a pet in the given world group.booleanhasPetInWorldGroup(String worldGroup) Returnstrueif this player has a pet in the named world group.booleanReturnstrueif the leash-flag helper overlay is shown.booleanReturnstrueif the under-name health bar is displayed.booleanisOnline()Returnstrueif the underlying Bukkit player is currently online.default voidMarks a pet as the player's selected pet: the one/petand every other command that takes an optional pet act on when none is named.voidsendActionBar(Component message) Sends an Adventure Component as an action bar message.voidsendMessage(Component message) Sends an Adventure Component chat message to the player.booleansendMessage(Component message, int cooldown) Sends a message with a cooldown (seconds).voidsetAutoRespawnEnabled(boolean flag) Enables or disables automatic respawning after death timer expires.voidsetAutoRespawnMin(int value) Sets the minimum respawn time (seconds) before auto-respawn fires.voidsetCaptureHelperActive(boolean captureHelperMode) Toggles the leash-flag helper overlay during taming attempts.voidsetHealthBarActive(boolean showHealthBar) Toggles the under-name health bar display.voidsetPetForWorldGroup(WorldGroup worldGroup, UUID petUUID) Binds a pet UUID as the active pet for the given world group.voidsetPetForWorldGroup(String worldGroup, UUID petUUID) Binds a pet UUID as the active pet for the given world group name.voidsetPetVolume(float volume) Sets the volume multiplier for sounds the pet emits.voidunbindPetFromWorldGroup(WorldGroup worldGroup, UUID petUUID) Removes one pet's binding, leaving the group's other pets bound.voidunbindPetFromWorldGroup(String worldGroup, UUID petUUID) Removes one pet's binding, leaving the group's other pets bound.Methods inherited from interface de.Keyle.MyPet.api.util.NBTStorage
load, save
-
Method Details
-
getName
String getName()Returns the player's current display name.- Returns:
- the player's current display name
-
hasCustomData
boolean hasCustomData()Whether this player has any non-default custom data persisted.- Returns:
trueif this player has any non-default data worth persisting
-
setAutoRespawnEnabled
void setAutoRespawnEnabled(boolean flag) Enables or disables automatic respawning after death timer expires.- Parameters:
flag-trueto respawn pets automatically once their timer expires
-
hasAutoRespawnEnabled
boolean hasAutoRespawnEnabled()Returnstrueif the pet will auto-respawn after its timer.- Returns:
trueif pets respawn automatically once their timer expires
-
getAutoRespawnMin
int getAutoRespawnMin()Returns the minimum respawn time (seconds) the player has configured.- Returns:
- the shortest remaining respawn time, in seconds, that still triggers an automatic respawn
-
setAutoRespawnMin
void setAutoRespawnMin(int value) Sets the minimum respawn time (seconds) before auto-respawn fires.- Parameters:
value- the shortest remaining respawn time, in seconds, that should still trigger an automatic respawn
-
getPetVolume
float getPetVolume()Returns the volume multiplier for sounds the pet emits.- Returns:
- the volume multiplier applied to pet sounds
-
setPetVolume
void setPetVolume(float volume) Sets the volume multiplier for sounds the pet emits.- Parameters:
volume- the volume multiplier to apply to pet sounds
-
isHealthBarActive
boolean isHealthBarActive()Returnstrueif the under-name health bar is displayed.- Returns:
trueif the health bar under the pet's name is shown
-
setHealthBarActive
void setHealthBarActive(boolean showHealthBar) Toggles the under-name health bar display.- Parameters:
showHealthBar-trueto show the health bar under the pet's name
-
isCaptureHelperActive
boolean isCaptureHelperActive()Returnstrueif the leash-flag helper overlay is shown.- Returns:
trueif the leash-flag overlay is shown during taming attempts
-
setCaptureHelperActive
void setCaptureHelperActive(boolean captureHelperMode) Toggles the leash-flag helper overlay during taming attempts.- Parameters:
captureHelperMode-trueto show the leash-flag overlay during taming attempts
-
setPetForWorldGroup
Binds a pet UUID as the active pet for the given world group name.- Parameters:
worldGroup- name of the world group to bind inpetUUID- the pet to bind
-
setPetForWorldGroup
Binds a pet UUID as the active pet for the given world group.- Parameters:
worldGroup- the world group to bind inpetUUID- the pet to bind
-
bindPetToWorldGroup
Binds an ADDITIONAL pet to the world group, keeping any pets already bound. A pet belongs to exactly one group, so this unbinds it from any other first.- Parameters:
worldGroup- name of the world group to bind inpetUUID- the pet to add to the group
-
bindPetToWorldGroup
Binds an ADDITIONAL pet to the world group, keeping any pets already bound.- Parameters:
worldGroup- the world group to bind inpetUUID- the pet to add to the group- See Also:
-
unbindPetFromWorldGroup
Removes one pet's binding, leaving the group's other pets bound.- Parameters:
worldGroup- name of the world group to unbind frompetUUID- the pet to unbind
-
unbindPetFromWorldGroup
Removes one pet's binding, leaving the group's other pets bound.- Parameters:
worldGroup- the world group to unbind frompetUUID- the pet to unbind- See Also:
-
getPetForWorldGroup
Returns the first (primary) pet bound to the given world group, ornull.- Parameters:
worldGroup- name of the world group to look in- Returns:
- the first pet bound to that group, or
nullif none is
-
getPetForWorldGroup
Returns the first (primary) pet bound to the given world group, ornull.- Parameters:
worldGroup- the world group to look in- Returns:
- the first pet bound to that group, or
nullif none is
-
getPetsForWorldGroup
Returns all pets bound to the given world group, in binding order.- Parameters:
worldGroup- name of the world group to look in- Returns:
- every pet bound to that group, in binding order
-
getPetsForWorldGroup
Returns all pets bound to the given world group, in binding order.- Parameters:
worldGroup- the world group to look in- Returns:
- every pet bound to that group, in binding order
-
getWorldGroupBindings
Returns the full world-group → pet UUID bindings.- Returns:
- every world-group-to-pet binding this player holds
-
getPetsForWorldGroups
Deprecated, for removal: This API element is subject to removal in a future version.a world group may hold more than one pet binding, which aBiMapcannot represent. UsegetWorldGroupBindings(). This method returns a snapshot containing only the first binding per group.Returns the primary world-group → pet UUID binding for each group.- Returns:
- a snapshot holding only the first pet bound to each world group
-
getWorldGroupForPet
Returns the world group name that a pet UUID is bound to.- Parameters:
petUUID- the pet to look up- Returns:
- the name of the world group that pet is bound to
-
hasPetInWorldGroup
Returnstrueif this player has a pet in the named world group.- Parameters:
worldGroup- name of the world group to check- Returns:
trueif this player has a pet bound there
-
hasPetInWorldGroup
Returnstrueif this player has a pet in the given world group.- Parameters:
worldGroup- the world group to check- Returns:
trueif this player has a pet bound there
-
addExtendedInfo
Stores a per-addon NBT value on this player. Keys are namespaced byownerso two addons cannot collide on the same key.- Parameters:
owner- the addon storing the value, which namespaces the keykey- the key to store undertag- the value to store
-
getExtendedInfo
Reads a per-addon NBT value from this player's namespaced bucket. Returns empty if the addon never wrotekey.- Parameters:
owner- the addon that stored the valuekey- the key to read- Returns:
- the stored value, or empty if that addon never wrote this key
-
isOnline
boolean isOnline()Returnstrueif the underlying Bukkit player is currently online.- Returns:
trueif the underlying Bukkit player is online
-
getUniqueId
UUID getUniqueId()Returns the player's Mojang UUID.- Returns:
- the player's Mojang UUID
-
getLanguage
String getLanguage()Returns the player's locale code (e.g."en_us").- Returns:
- the player's locale code, such as
"en_us"
-
hasPet
boolean hasPet()Returnstrueif this player has at least one active (live) pet.- Returns:
trueif this player has at least one active pet
-
getPrimaryPet
Pet getPrimaryPet()Returns the player's primary active pet — the first one activated that is still active — ornullif none is active in the current world group.Prefer
getPets()for anything that should affect every pet the player has out. This accessor is for call sites that genuinely mean one specific pet: a default for a command whose pet argument was omitted, an un-indexed placeholder, a fallback when a tag cannot be resolved.- Returns:
- the player's primary active pet, or
nullif none is active in the current world group
-
getPet
Deprecated.the name says "the pet" from an era when a player could only have one out, and it silently answers for the primary now that they can have several. UsegetPets()when the answer should cover the whole roster, orgetPrimaryPet()when the primary really is what you mean. Kept working for addons built before multi-pet support.- Returns:
- the player's primary active pet, or
nullif none is active
-
getPets
Returns all of this player's active pets, in activation order. Nevernull.- Returns:
- every active pet, in activation order; never
null
-
selectPet
Marks a pet as the player's selected pet: the one/petand every other command that takes an optional pet act on when none is named. Set whenever the player brings a pet out and when they pick one in the pet menu; the restore paths (join, world change, plugin enable) leave it alone. Persisted with the player.- Parameters:
petUUID- the pet to select;nullis ignored
-
getSelectedPetUUID
The UUID last passed toselectPet(java.util.UUID), ornull. It need not be out any more;PetManager.getSelectedPet(de.Keyle.MyPet.api.player.MyPetPlayer)resolves that.- Returns:
- the selected pet's UUID, or
nullif none was selected
-
getPetCount
Deprecated, for removal: This API element is subject to removal in a future version.usegetPets().size(), which this equalsReturns the number of currently active pets for this player.- Returns:
- how many pets this player currently has active
-
getPlayer
Player getPlayer()Returns the underlying Bukkit player. Only valid whenisOnline()istrue.- Returns:
- the underlying Bukkit player, valid only while
isOnline()istrue
-
sendMessage
Sends an Adventure Component chat message to the player.- Parameters:
message- the message to send
-
sendMessage
Sends a message with a cooldown (seconds). Returnstrueif the message was sent,falseif suppressed by the cooldown.- Parameters:
message- the message to sendcooldown- seconds to suppress an identical message for- Returns:
trueif the message was sent,falseif the cooldown suppressed it
-
sendActionBar
Sends an Adventure Component as an action bar message.- Parameters:
message- the message to show on the action bar
-