Refined PR

This commit is contained in:
Auxilor
2022-09-28 15:56:20 +01:00
parent 6c1b283b1b
commit 6f56b11b21
3 changed files with 19 additions and 15 deletions

View File

@@ -32,7 +32,7 @@ import org.bukkit.OfflinePlayer
import org.bukkit.entity.Player
import org.bukkit.inventory.ItemStack
import org.bukkit.persistence.PersistentDataType
import java.util.*
import java.util.Objects
import java.util.concurrent.TimeUnit
import kotlin.math.abs
@@ -113,8 +113,7 @@ class Pet(
}
val entityTexture = config.getString("entity-texture")
val entityAnimation = config.getString("default-animation")
val modelEngineAnimation = config.getStringOrNull("modelengine-animation")
private val levelXpRequirements = listOf(0) + config.getInts("level-xp-requirements")

View File

@@ -8,25 +8,29 @@ import org.bukkit.entity.ArmorStand
class ModelEnginePetEntity(
pet: Pet,
private val modelID: String
private val modelID: String,
private val plugin: EcoPetsPlugin
) : PetEntity(pet) {
override fun spawn(location: Location): ArmorStand {
val stand = emptyArmorStandAt(location, pet)
val entityAnimation = pet.entityAnimation
val meAnimation = pet.modelEngineAnimation
val model = ModelEngineAPI.createActiveModel(modelID)
val animationHandler = model.animationHandler
val animationProperty = animationHandler.getAnimation(entityAnimation)
if (animationProperty != null) {
animationHandler.playAnimation(animationProperty, true)
} else {
EcoPetsPlugin.instance.logger.warning("$entityAnimation not found in model $modelID, im use walk animation")
val animationPropertyWalk = animationHandler.getAnimation("walk")
if (animationPropertyWalk != null) {
animationHandler.playAnimation(animationPropertyWalk, true)
if (meAnimation != null) {
val animationHandler = model.animationHandler
val animationProperty = animationHandler.getAnimation(meAnimation)
if (animationProperty != null) {
animationHandler.playAnimation(animationProperty, true)
} else {
EcoPetsPlugin.instance.logger.warning("walk animation not found in $modelID, you have any animation!?")
plugin.logger.warning("Animation $meAnimation not found in model $modelID, defaulting to walk!")
val animationPropertyWalk = animationHandler.getAnimation("walk")
if (animationPropertyWalk != null) {
animationHandler.playAnimation(animationPropertyWalk, true)
} else {
plugin.logger.warning("Walk animation not found in $modelID!")
}
}
}

View File

@@ -116,6 +116,7 @@ conditions: [ ]
# The texture of the pet entity in game
# If you're using modelengine, use modelengine:id as the texture
entity-texture: "eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvOTA5NWZjYzFlM2Q3Y2JkMzUwZjE5YjM4OTQ5OGFiOGJiOTZjNjVhZDE4NWQzNDU5MjA2N2E3ZDAzM2FjNDhkZSJ9fX0="
modelengine-animation: "fly" # If you're using ModelEngine, you can specify an animation here
# The icon in GUIs
icon: player_head texture:eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvOTA5NWZjYzFlM2Q3Y2JkMzUwZjE5YjM4OTQ5OGFiOGJiOTZjNjVhZDE4NWQzNDU5MjA2N2E3ZDAzM2FjNDhkZSJ9fX0=