Package de.Keyle.MyPet.api.entity
Class PetInfo
java.lang.Object
de.Keyle.MyPet.api.entity.PetInfo
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 Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidaddFood(PetType type, ConfigItem foodToAdd) Adds a food item if not already registered (duplicate-safe).voidaddLeashFlagSetting(PetType type, Settings setting) Adds a leash flag to the conditions checked before this type can be tamed.voidForgets every food configured for a type.voidclearLeashFlagSettings(PetType petType) Forgets every leash flag configured for a type.intPer-level multiplier added to the base respawn timer.intFlat respawn time (seconds) added regardless of pet level.doublegetFlySpeed(PetType petType) Per-pet fly-speed value used by the Ride skill's flight controller whenisOverrideFlySpeed(PetType)returnstrue.Returns the list of items that restore saturation for this type.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).getLeashItem(PetType type) The item the player must use to leash (tame) this mob type, ornullif the default (lead) applies.booleangetReleaseOnDeath(PetType petType) Reports whether pets of a type are released when they die.booleangetRemoveAfterRelease(PetType petType) Reports whether the mob is removed once a pet of this type is released.doubleBase walk speed (Bukkit MOVEMENT_SPEED attribute value).doublegetStartHP(PetType type) Starting max health for freshly tamed pets of this type.doublegetTeleportDistance(PetType type) Distance in blocks at which a pet oftypethat has fallen behind its owner teleports to them (MyPet.Pets.<Type>.TeleportDistance).abstract booleanReturns whether a given BukkitEntityTypecan be leashed as a pet at all.booleanisOverrideFlySpeed(PetType petType) Per-pet toggle controlling whether the Ride skill's flight controller usesgetFlySpeed(PetType)verbatim or derives ride speed from the mob's vanillaFLYING_SPEED/MOVEMENT_SPEEDattribute.voidsetCustomRespawnTimeFactor(PetType type, int factor) Sets the per-level term of a type's respawn wait.voidsetCustomRespawnTimeFixed(PetType type, int factor) Sets the flat term of a type's respawn wait.voidsetFlySpeed(PetType type, double flySpeed) Sets a type's ride flight speed.voidsetLeashItem(PetType type, ConfigItem configItem) Sets the item used to tame a type.voidsetOverrideFlySpeed(PetType type, boolean override) Sets whether a type overrides the ride flight speed.voidsetReleaseOnDeath(PetType petType, boolean releaseOnDeath) Iftrue, the pet is permanently released (deleted) when it dies instead of entering the respawn timer.voidsetRemoveAfterRelease(PetType petType, boolean removeAfterRelease) Iftrue, the Bukkit entity is removed from the world immediately after releasing the pet (rather than leaving the mob alive as a wild entity).voidSets a type's walk speed.voidsetStartHP(PetType type, double hp) Sets the health a newly tamed pet of a type starts with.voidsetTeleportDistance(PetType type, double distance) Sets the teleport distance fortype.
-
Constructor Details
-
PetInfo
public PetInfo()Creates a registry. MyPet supplies the implementation; addons read it through the API.
-
-
Method Details
-
getTeleportDistance
Distance in blocks at which a pet oftypethat has fallen behind its owner teleports to them (MyPet.Pets.<Type>.TeleportDistance).- Parameters:
type- the pet type- Returns:
- the teleport distance,
32.0when unset
-
setTeleportDistance
Sets the teleport distance fortype.- Parameters:
type- the pet typedistance- the distance in blocks
-
getCustomRespawnTimeFactor
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
Sets the per-level term of a type's respawn wait.- Parameters:
type- the pet type to configurefactor- seconds added per pet level
-
getCustomRespawnTimeFixed
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
Sets the flat term of a type's respawn wait.- Parameters:
type- the pet type to configurefactor- seconds added regardless of level
-
getFood
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
Forgets every food configured for a type.- Parameters:
type- the pet type to clear
-
addFood
Adds a food item if not already registered (duplicate-safe).- Parameters:
type- the pet type to extendfoodToAdd- the item to accept as food
-
getLeashFlagSettings
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
Adds a leash flag to the conditions checked before this type can be tamed.- Parameters:
type- the pet type to extendsetting- the flag and its parameters
-
clearLeashFlagSettings
Forgets every leash flag configured for a type.- Parameters:
petType- the pet type to clear
-
getStartHP
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
Sets the health a newly tamed pet of a type starts with.- Parameters:
type- the pet type to configurehp- starting health in half-hearts
-
getLeashItem
The item the player must use to leash (tame) this mob type, ornullif the default (lead) applies.- Parameters:
type- the pet type to read- Returns:
- the item used to tame that type
-
setLeashItem
Sets the item used to tame a type.- Parameters:
type- the pet type to configureconfigItem- the taming item
-
getSpeed
Base walk speed (Bukkit MOVEMENT_SPEED attribute value). Falls back to0.3if no override is configured.- Parameters:
petType- the pet type to read- Returns:
- the walk speed for that type
-
setSpeed
Sets a type's walk speed.- Parameters:
type- the pet type to configurespeed- the movement speed attribute value
-
isOverrideFlySpeed
Per-pet toggle controlling whether the Ride skill's flight controller usesgetFlySpeed(PetType)verbatim or derives ride speed from the mob's vanillaFLYING_SPEED/MOVEMENT_SPEEDattribute. Default isfalse(derive from vanilla); settrueviasetOverrideFlySpeed(PetType, boolean)(or theMyPet.Pets.<Type>.OverrideFlySpeedYAML key, or the@DefaultInfo#overrideFlySpeedannotation field) to lock the ride speed to the configuredFlySpeedvalue.- Parameters:
petType- the pet type to read- Returns:
trueif that type overrides the ride flight speed
-
setOverrideFlySpeed
Sets whether a type overrides the ride flight speed.- Parameters:
type- the pet type to configureoverride-trueto use the type's own fly speed
-
getFlySpeed
Per-pet fly-speed value used by the Ride skill's flight controller whenisOverrideFlySpeed(PetType)returnstrue. Authored in direct-per-tick-velocity units. When the toggle isfalse, this value is ignored and the controller derives speed from the live Bukkit mob'sFLYING_SPEED/MOVEMENT_SPEEDattribute. Falls back to0.6if no override is configured.- Parameters:
petType- the pet type to read- Returns:
- the ride flight speed for that type
-
setFlySpeed
Sets a type's ride flight speed.- Parameters:
type- the pet type to configureflySpeed- blocks per tick
-
isLeashableEntityType
Returns whether a given BukkitEntityTypecan be leashed as a pet at all. The implementation typically checks version gates and the registeredPetTypeset.- Parameters:
type- the Bukkit entity type to test- Returns:
trueif a mob of that type can be tamed
-
setReleaseOnDeath
Iftrue, the pet is permanently released (deleted) when it dies instead of entering the respawn timer.- Parameters:
petType- the pet type to configurereleaseOnDeath- whether such pets are released when they die
-
setRemoveAfterRelease
Iftrue, 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 configureremoveAfterRelease- whether the mob is removed after release
-
getReleaseOnDeath
Reports whether pets of a type are released when they die.- Parameters:
petType- the pet type to read- Returns:
trueif such pets are released on death
-
getRemoveAfterRelease
Reports whether the mob is removed once a pet of this type is released.- Parameters:
petType- the pet type to read- Returns:
trueif the mob is removed after release
-