Interface MyPetPlayer

All Superinterfaces:
NBTStorage, Scheduler

public interface MyPetPlayer extends Scheduler, NBTStorage
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 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:
      true if 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 - true to respawn pets automatically once their timer expires
    • hasAutoRespawnEnabled

      boolean hasAutoRespawnEnabled()
      Returns true if the pet will auto-respawn after its timer.
      Returns:
      true if 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()
      Returns true if the under-name health bar is displayed.
      Returns:
      true if the health bar under the pet's name is shown
    • setHealthBarActive

      void setHealthBarActive(boolean showHealthBar)
      Toggles the under-name health bar display.
      Parameters:
      showHealthBar - true to show the health bar under the pet's name
    • isCaptureHelperActive

      boolean isCaptureHelperActive()
      Returns true if the leash-flag helper overlay is shown.
      Returns:
      true if 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 - true to show the leash-flag overlay during taming attempts
    • setPetForWorldGroup

      void setPetForWorldGroup(String worldGroup, UUID petUUID)
      Binds a pet UUID as the active pet for the given world group name.
      Parameters:
      worldGroup - name of the world group to bind in
      petUUID - the pet to bind
    • setPetForWorldGroup

      void setPetForWorldGroup(WorldGroup worldGroup, UUID petUUID)
      Binds a pet UUID as the active pet for the given world group.
      Parameters:
      worldGroup - the world group to bind in
      petUUID - the pet to bind
    • bindPetToWorldGroup

      void bindPetToWorldGroup(String worldGroup, UUID petUUID)
      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 in
      petUUID - the pet to add to the group
    • bindPetToWorldGroup

      void bindPetToWorldGroup(WorldGroup worldGroup, UUID petUUID)
      Binds an ADDITIONAL pet to the world group, keeping any pets already bound.
      Parameters:
      worldGroup - the world group to bind in
      petUUID - the pet to add to the group
      See Also:
    • unbindPetFromWorldGroup

      void unbindPetFromWorldGroup(String worldGroup, UUID petUUID)
      Removes one pet's binding, leaving the group's other pets bound.
      Parameters:
      worldGroup - name of the world group to unbind from
      petUUID - the pet to unbind
    • unbindPetFromWorldGroup

      void unbindPetFromWorldGroup(WorldGroup worldGroup, UUID petUUID)
      Removes one pet's binding, leaving the group's other pets bound.
      Parameters:
      worldGroup - the world group to unbind from
      petUUID - the pet to unbind
      See Also:
    • getPetForWorldGroup

      UUID getPetForWorldGroup(String worldGroup)
      Returns the first (primary) pet bound to the given world group, or null.
      Parameters:
      worldGroup - name of the world group to look in
      Returns:
      the first pet bound to that group, or null if none is
    • getPetForWorldGroup

      UUID getPetForWorldGroup(WorldGroup worldGroup)
      Returns the first (primary) pet bound to the given world group, or null.
      Parameters:
      worldGroup - the world group to look in
      Returns:
      the first pet bound to that group, or null if none is
    • getPetsForWorldGroup

      List<UUID> getPetsForWorldGroup(String worldGroup)
      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

      List<UUID> getPetsForWorldGroup(WorldGroup worldGroup)
      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

      Multimap<String,UUID> getWorldGroupBindings()
      Returns the full world-group → pet UUID bindings.
      Returns:
      every world-group-to-pet binding this player holds
    • getPetsForWorldGroups

      @Deprecated(since="4.1.0", forRemoval=true) BiMap<String,UUID> 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 a BiMap cannot represent. Use getWorldGroupBindings(). 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

      String getWorldGroupForPet(UUID petUUID)
      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

      boolean hasPetInWorldGroup(String worldGroup)
      Returns true if this player has a pet in the named world group.
      Parameters:
      worldGroup - name of the world group to check
      Returns:
      true if this player has a pet bound there
    • hasPetInWorldGroup

      boolean hasPetInWorldGroup(WorldGroup worldGroup)
      Returns true if this player has a pet in the given world group.
      Parameters:
      worldGroup - the world group to check
      Returns:
      true if this player has a pet bound there
    • addExtendedInfo

      void addExtendedInfo(Plugin owner, String key, BinaryTag tag)
      Stores a per-addon NBT value on this player. Keys are namespaced by owner so two addons cannot collide on the same key.
      Parameters:
      owner - the addon storing the value, which namespaces the key
      key - the key to store under
      tag - the value to store
    • getExtendedInfo

      Optional<BinaryTag> getExtendedInfo(Plugin owner, String key)
      Reads a per-addon NBT value from this player's namespaced bucket. Returns empty if the addon never wrote key.
      Parameters:
      owner - the addon that stored the value
      key - the key to read
      Returns:
      the stored value, or empty if that addon never wrote this key
    • isOnline

      boolean isOnline()
      Returns true if the underlying Bukkit player is currently online.
      Returns:
      true if 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()
      Returns true if this player has at least one active (live) pet.
      Returns:
      true if 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 — or null if 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 null if none is active in the current world group
    • getPet

      @Deprecated default Pet 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. Use getPets() when the answer should cover the whole roster, or getPrimaryPet() 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 null if none is active
    • getPets

      List<Pet> getPets()
      Returns all of this player's active pets, in activation order. Never null.
      Returns:
      every active pet, in activation order; never null
    • selectPet

      default void selectPet(UUID petUUID)
      Marks a pet as the player's selected pet: the one /pet and 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; null is ignored
    • getSelectedPetUUID

      default UUID getSelectedPetUUID()
      The UUID last passed to selectPet(java.util.UUID), or null. It need not be out any more; PetManager.getSelectedPet(de.Keyle.MyPet.api.player.MyPetPlayer) resolves that.
      Returns:
      the selected pet's UUID, or null if none was selected
    • getPetCount

      @Deprecated(since="4.1.0", forRemoval=true) int getPetCount()
      Deprecated, for removal: This API element is subject to removal in a future version.
      use getPets().size(), which this equals
      Returns 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 when isOnline() is true.
      Returns:
      the underlying Bukkit player, valid only while isOnline() is true
    • sendMessage

      void sendMessage(Component message)
      Sends an Adventure Component chat message to the player.
      Parameters:
      message - the message to send
    • sendMessage

      boolean sendMessage(Component message, int cooldown)
      Sends a message with a cooldown (seconds). Returns true if the message was sent, false if suppressed by the cooldown.
      Parameters:
      message - the message to send
      cooldown - seconds to suppress an identical message for
      Returns:
      true if the message was sent, false if the cooldown suppressed it
    • sendActionBar

      void sendActionBar(Component message)
      Sends an Adventure Component as an action bar message.
      Parameters:
      message - the message to show on the action bar