From 6fb565f6db8e621c83e402d42fd1c68b6394cb42 Mon Sep 17 00:00:00 2001 From: Auxilor Date: Fri, 4 Nov 2022 13:11:02 +0000 Subject: [PATCH] Added setActivePet to API --- .../com/willfp/ecopets/EcoPetsAPIImpl.kt | 4 +++ .../com/willfp/ecopets/api/EcoPetsAPI.kt | 32 +++++++++++++------ 2 files changed, 26 insertions(+), 10 deletions(-) diff --git a/eco-core/core-plugin/src/main/kotlin/com/willfp/ecopets/EcoPetsAPIImpl.kt b/eco-core/core-plugin/src/main/kotlin/com/willfp/ecopets/EcoPetsAPIImpl.kt index f142c51..f0bb3a5 100644 --- a/eco-core/core-plugin/src/main/kotlin/com/willfp/ecopets/EcoPetsAPIImpl.kt +++ b/eco-core/core-plugin/src/main/kotlin/com/willfp/ecopets/EcoPetsAPIImpl.kt @@ -17,6 +17,10 @@ internal object EcoPetsAPIImpl : EcoPetsAPI { override fun getActivePet(player: OfflinePlayer): Pet? = player.activePet + override fun setActivePet(player: OfflinePlayer, pet: Pet?) { + player.activePet = pet + } + override fun getPetLevel(player: OfflinePlayer, pet: Pet) = player.getPetLevel(pet) override fun givePetExperience(player: Player, pet: Pet, amount: Double) = diff --git a/eco-core/core-plugin/src/main/kotlin/com/willfp/ecopets/api/EcoPetsAPI.kt b/eco-core/core-plugin/src/main/kotlin/com/willfp/ecopets/api/EcoPetsAPI.kt index 8d1eabb..17eab6b 100644 --- a/eco-core/core-plugin/src/main/kotlin/com/willfp/ecopets/api/EcoPetsAPI.kt +++ b/eco-core/core-plugin/src/main/kotlin/com/willfp/ecopets/api/EcoPetsAPI.kt @@ -10,7 +10,7 @@ interface EcoPetsAPI { * Get if a player has a pet. * * @param player The player. - * @param pet The pet. + * @param pet The pet. * @return If the player has the pet unlocked */ fun hasPet( @@ -28,11 +28,22 @@ interface EcoPetsAPI { player: OfflinePlayer ): Pet? + /** + * Set a player's active pet. + * + * @param player The player. + * @param pet The pet. + */ + fun setActivePet( + player: OfflinePlayer, + pet: Pet? + ) + /** * Get a player's level of a certain pet. * * @param player The player. - * @param pet The pet. + * @param pet The pet. * @return The level. */ fun getPetLevel( @@ -44,7 +55,7 @@ interface EcoPetsAPI { * Give pet experience to a player. * * @param player The player. - * @param pet The pet. + * @param pet The pet. * @param amount The amount of experience to give. */ fun givePetExperience( @@ -56,9 +67,9 @@ interface EcoPetsAPI { /** * Give pet experience to a player. * - * @param player The player. - * @param pet The pet. - * @param amount The amount of experience to give. + * @param player The player. + * @param pet The pet. + * @param amount The amount of experience to give. * @param applyMultipliers If multipliers should be applied. */ fun givePetExperience( @@ -69,10 +80,11 @@ interface EcoPetsAPI { ) /** - * Get progress to next level between 0 and 1, where 0 is none and 1 is complete. + * Get progress to next level between 0 and 1, where 0 is none and 1 is + * complete. * * @param player The player. - * @param pet The pet. + * @param pet The pet. * @return The progress. */ fun getPetProgress( @@ -84,7 +96,7 @@ interface EcoPetsAPI { * Get the experience required to advance to the next level. * * @param player The player. - * @param pet The pet. + * @param pet The pet. * @return The experience required. */ fun getPetXPRequired( @@ -96,7 +108,7 @@ interface EcoPetsAPI { * Get experience to the next level. * * @param player The player. - * @param pet The pet. + * @param pet The pet. * @return The experience. */ fun getPetXP(