diff --git a/eco-core/core-plugin/src/main/kotlin/com/willfp/ecobosses/util/EntityDamageTracking.kt b/eco-core/core-plugin/src/main/kotlin/com/willfp/ecobosses/util/EntityDamageTracking.kt index c105b3e..067d61a 100644 --- a/eco-core/core-plugin/src/main/kotlin/com/willfp/ecobosses/util/EntityDamageTracking.kt +++ b/eco-core/core-plugin/src/main/kotlin/com/willfp/ecobosses/util/EntityDamageTracking.kt @@ -18,7 +18,7 @@ private const val metaKey = "TOP_DAMAGERS" @Suppress("UNCHECKED_CAST") var LivingEntity.topDamagers: List - get() = (this.getMetadata(metaKey).getOrNull(0) as? List) ?: emptyList() + get() = (this.getMetadata(metaKey).getOrNull(0)?.value() as? List) ?: emptyList() private set(value) { this.removeMetadata(metaKey, EcoBossesPlugin.instance) this.setMetadata(metaKey, EcoBossesPlugin.instance.metadataValueFactory.create(value)) diff --git a/eco-core/core-plugin/src/main/kotlin/com/willfp/ecobosses/util/LocalBroadcast.kt b/eco-core/core-plugin/src/main/kotlin/com/willfp/ecobosses/util/LocalBroadcast.kt index 84f0457..19ba0f4 100644 --- a/eco-core/core-plugin/src/main/kotlin/com/willfp/ecobosses/util/LocalBroadcast.kt +++ b/eco-core/core-plugin/src/main/kotlin/com/willfp/ecobosses/util/LocalBroadcast.kt @@ -1,8 +1,10 @@ package com.willfp.ecobosses.util import com.willfp.eco.core.config.interfaces.Config +import com.willfp.eco.util.NumberUtils import com.willfp.eco.util.formatEco import com.willfp.eco.util.savedDisplayName +import com.willfp.ecobosses.EcoBossesPlugin import org.bukkit.Bukkit import org.bukkit.Location import org.bukkit.entity.Player @@ -15,9 +17,16 @@ data class LocalBroadcast( val toBroadcast = messages.toMutableList() toBroadcast.replaceAll { var message = it - for ((index, damager) in topDamagers.withIndex()) { - message = message.replace("%damage_${index + 1}%", damager.damage.toString()) - .replace("%damage_${index + 1}_player%", Bukkit.getOfflinePlayer(damager.uuid).savedDisplayName) + + for (i in 1..20) { + val damager = topDamagers.getOrNull(i - 1) + val damage = if (damager?.damage != null) NumberUtils.format(damager.damage) else + EcoBossesPlugin.instance.langYml.getFormattedString("na") + val player = if (damager?.uuid != null) Bukkit.getOfflinePlayer(damager.uuid).savedDisplayName else + EcoBossesPlugin.instance.langYml.getFormattedString("na") + + message = message.replace("%damage_${i}%", damage) + .replace("%damage_${i}_player%", player) } message = message.replace("%x%", location.blockX.toString())