Class PetInfo

java.lang.Object
de.Keyle.MyPet.api.entity.PetInfo

public abstract class PetInfo extends Object
Per-type metadata registry. Stores the configurable attributes that vary by pet type — starting HP, walk speed, food items, leash flags, respawn timers, and death behaviour. Populated at startup from DefaultInfo annotations (hardcoded defaults) then overwritten by values loaded from pet-config.yml.

Accessed globally via MyPetApi.getPetInfo(). The concrete implementation (PetInfoImpl in the plugin module) adds leashability checks and any version-gated type filtering.

  • Constructor Details

    • PetInfo

      public PetInfo()
      Creates a registry. MyPet supplies the implementation; addons read it through the API.
  • Method Details

    • getTeleportDistance

      public double getTeleportDistance(PetType type)
      Distance in blocks at which a pet of type that has fallen behind its owner teleports to them (MyPet.Pets.<Type>.TeleportDistance).
      Parameters:
      type - the pet type
      Returns:
      the teleport distance, 32.0 when unset
    • setTeleportDistance

      public void setTeleportDistance(PetType type, double distance)
      Sets the teleport distance for type.
      Parameters:
      type - the pet type
      distance - the distance in blocks
    • getCustomRespawnTimeFactor

      public int getCustomRespawnTimeFactor(PetType type)
      Per-level multiplier added to the base respawn timer. Total respawn time = fixed + (factor * petLevel).
      Parameters:
      type - the pet type to read
      Returns:
      the per-level respawn term configured for that type
    • setCustomRespawnTimeFactor

      public void setCustomRespawnTimeFactor(PetType type, int factor)
      Sets the per-level term of a type's respawn wait.
      Parameters:
      type - the pet type to configure
      factor - seconds added per pet level
    • getCustomRespawnTimeFixed

      public int getCustomRespawnTimeFixed(PetType type)
      Flat respawn time (seconds) added regardless of pet level.
      Parameters:
      type - the pet type to read
      Returns:
      the flat respawn term configured for that type
    • setCustomRespawnTimeFixed

      public void setCustomRespawnTimeFixed(PetType type, int factor)
      Sets the flat term of a type's respawn wait.
      Parameters:
      type - the pet type to configure
      factor - seconds added regardless of level
    • getFood

      public List<ConfigItem> getFood(PetType type)
      Returns the list of items that restore saturation for this type.
      Parameters:
      type - the pet type to read
      Returns:
      the items that feed that type
    • clearFood

      public void clearFood(PetType type)
      Forgets every food configured for a type.
      Parameters:
      type - the pet type to clear
    • addFood

      public void addFood(PetType type, ConfigItem foodToAdd)
      Adds a food item if not already registered (duplicate-safe).
      Parameters:
      type - the pet type to extend
      foodToAdd - the item to accept as food
    • getLeashFlagSettings

      public List<Settings> getLeashFlagSettings(PetType type)
      Returns the configured leash flag settings for a pet type — each entry corresponds to one flag with its per-flag parameters (e.g., chance percentage, required size).
      Parameters:
      type - the pet type to read
      Returns:
      the configured leash flags for that type
    • addLeashFlagSetting

      public void addLeashFlagSetting(PetType type, Settings setting)
      Adds a leash flag to the conditions checked before this type can be tamed.
      Parameters:
      type - the pet type to extend
      setting - the flag and its parameters
    • clearLeashFlagSettings

      public void clearLeashFlagSettings(PetType petType)
      Forgets every leash flag configured for a type.
      Parameters:
      petType - the pet type to clear
    • getStartHP

      public double getStartHP(PetType type)
      Starting max health for freshly tamed pets of this type.
      Parameters:
      type - the pet type to read
      Returns:
      the health a newly tamed pet of that type starts with
    • setStartHP

      public void setStartHP(PetType type, double hp)
      Sets the health a newly tamed pet of a type starts with.
      Parameters:
      type - the pet type to configure
      hp - starting health in half-hearts
    • getLeashItem

      public ConfigItem getLeashItem(PetType type)
      The item the player must use to leash (tame) this mob type, or null if the default (lead) applies.
      Parameters:
      type - the pet type to read
      Returns:
      the item used to tame that type
    • setLeashItem

      public void setLeashItem(PetType type, ConfigItem configItem)
      Sets the item used to tame a type.
      Parameters:
      type - the pet type to configure
      configItem - the taming item
    • getSpeed

      public double getSpeed(PetType petType)
      Base walk speed (Bukkit MOVEMENT_SPEED attribute value). Falls back to 0.3 if no override is configured.
      Parameters:
      petType - the pet type to read
      Returns:
      the walk speed for that type
    • setSpeed

      public void setSpeed(PetType type, double speed)
      Sets a type's walk speed.
      Parameters:
      type - the pet type to configure
      speed - the movement speed attribute value
    • isOverrideFlySpeed

      public boolean isOverrideFlySpeed(PetType petType)
      Per-pet toggle controlling whether the Ride skill's flight controller uses getFlySpeed(PetType) verbatim or derives ride speed from the mob's vanilla FLYING_SPEED / MOVEMENT_SPEED attribute. Default is false (derive from vanilla); set true via setOverrideFlySpeed(PetType, boolean) (or the MyPet.Pets.<Type>.OverrideFlySpeed YAML key, or the @DefaultInfo#overrideFlySpeed annotation field) to lock the ride speed to the configured FlySpeed value.
      Parameters:
      petType - the pet type to read
      Returns:
      true if that type overrides the ride flight speed
    • setOverrideFlySpeed

      public void setOverrideFlySpeed(PetType type, boolean override)
      Sets whether a type overrides the ride flight speed.
      Parameters:
      type - the pet type to configure
      override - true to use the type's own fly speed
    • getFlySpeed

      public double getFlySpeed(PetType petType)
      Per-pet fly-speed value used by the Ride skill's flight controller when isOverrideFlySpeed(PetType) returns true. Authored in direct-per-tick-velocity units. When the toggle is false, this value is ignored and the controller derives speed from the live Bukkit mob's FLYING_SPEED / MOVEMENT_SPEED attribute. Falls back to 0.6 if no override is configured.
      Parameters:
      petType - the pet type to read
      Returns:
      the ride flight speed for that type
    • setFlySpeed

      public void setFlySpeed(PetType type, double flySpeed)
      Sets a type's ride flight speed.
      Parameters:
      type - the pet type to configure
      flySpeed - blocks per tick
    • isLeashableEntityType

      public abstract boolean isLeashableEntityType(EntityType type)
      Returns whether a given Bukkit EntityType can be leashed as a pet at all. The implementation typically checks version gates and the registered PetType set.
      Parameters:
      type - the Bukkit entity type to test
      Returns:
      true if a mob of that type can be tamed
    • setReleaseOnDeath

      public void setReleaseOnDeath(PetType petType, boolean releaseOnDeath)
      If true, the pet is permanently released (deleted) when it dies instead of entering the respawn timer.
      Parameters:
      petType - the pet type to configure
      releaseOnDeath - whether such pets are released when they die
    • setRemoveAfterRelease

      public void setRemoveAfterRelease(PetType petType, boolean removeAfterRelease)
      If true, the Bukkit entity is removed from the world immediately after releasing the pet (rather than leaving the mob alive as a wild entity).
      Parameters:
      petType - the pet type to configure
      removeAfterRelease - whether the mob is removed after release
    • getReleaseOnDeath

      public boolean getReleaseOnDeath(PetType petType)
      Reports whether pets of a type are released when they die.
      Parameters:
      petType - the pet type to read
      Returns:
      true if such pets are released on death
    • getRemoveAfterRelease

      public boolean getRemoveAfterRelease(PetType petType)
      Reports whether the mob is removed once a pet of this type is released.
      Parameters:
      petType - the pet type to read
      Returns:
      true if the mob is removed after release