9
0
mirror of https://github.com/Auxilor/EcoMobs.git synced 2025-12-19 15:09:17 +00:00

Added %health_percent% placeholder

This commit is contained in:
Auxilor
2023-11-13 11:28:32 +00:00
parent f2170278f8
commit 38f9b6df64
3 changed files with 19 additions and 1 deletions

View File

@@ -14,6 +14,7 @@ import com.willfp.ecomobs.mob.event.impl.MobEventRangedAttack
import com.willfp.ecomobs.mob.event.impl.MobEventSpawn
import com.willfp.ecomobs.mob.event.impl.MobEventTakeDamage
import com.willfp.ecomobs.mob.placeholder.impl.MobPlaceholderHealth
import com.willfp.ecomobs.mob.placeholder.impl.MobPlaceholderHealthPercent
import com.willfp.ecomobs.mob.placeholder.impl.MobPlaceholderMaxHealth
import com.willfp.ecomobs.mob.placeholder.impl.MobPlaceholderTime
@@ -21,6 +22,7 @@ object MobPlaceholders : Registry<MobPlaceholder>() {
init {
register(MobPlaceholderHealth)
register(MobPlaceholderMaxHealth)
register(MobPlaceholderHealthPercent)
register(MobPlaceholderTime)
}
}

View File

@@ -0,0 +1,14 @@
package com.willfp.ecomobs.mob.placeholder.impl
import com.willfp.eco.util.toNiceString
import com.willfp.ecomobs.mob.LivingMob
import com.willfp.ecomobs.mob.placeholder.MobPlaceholder
object MobPlaceholderHealthPercent : MobPlaceholder("health_percent") {
override fun getValue(mob: LivingMob): String {
val health = mob.entity.health
val maxHealth = mob.entity.getAttribute(org.bukkit.attribute.Attribute.GENERIC_MAX_HEALTH)?.value ?: return "0"
return (health / maxHealth * 100).toNiceString()
}
}

View File

@@ -11,7 +11,8 @@ mob: zombie attack-damage:90 movement-speed:1.5 follow-range:16 health:1200
# The ID of the mob category, handles spawning.
category: common
# Supported placeholders: %health%, %time% (formats as minutes:seconds, eg 1:56)
# Supported placeholders:
# %health%, %max_health%, %health_percent%, %time% (formats as minutes:seconds, eg 1:56)
display-name: "&cNecrotic Soldier &7| &c%health%♥ &7| &e%time%"
# If the mob you're using supports equipment, you can specify the items in each slot.
@@ -53,6 +54,7 @@ custom-ai:
# Effects are done from the player's perspective: to treat the player as the victim,
# either use self_as_victim in args, or use player_as_victim in mutators.
# You can use display name placeholders in effects
effects:
# Effects ran when the mob spawns
spawn: [ ]