mirror of
https://github.com/Auxilor/EcoSkills.git
synced 2026-01-02 22:02:19 +00:00
Removed semi-dependency on PAPI player
This commit is contained in:
@@ -4,11 +4,15 @@ import com.willfp.eco.core.EcoPlugin
|
||||
import com.willfp.eco.core.data.keys.PersistentDataKey
|
||||
import com.willfp.eco.core.data.keys.PersistentDataKeyType
|
||||
import com.willfp.eco.core.data.profile
|
||||
import com.willfp.eco.core.placeholder.InjectablePlaceholder
|
||||
import com.willfp.eco.core.placeholder.PlaceholderInjectable
|
||||
import com.willfp.eco.core.placeholder.PlayerStaticPlaceholder
|
||||
import com.willfp.eco.core.placeholder.context.placeholderContext
|
||||
import com.willfp.eco.util.containsIgnoreCase
|
||||
import com.willfp.eco.util.namespacedKeyOf
|
||||
import org.bukkit.Bukkit
|
||||
import org.bukkit.GameMode
|
||||
import org.bukkit.attribute.Attribute
|
||||
import org.bukkit.entity.Player
|
||||
import org.bukkit.event.EventHandler
|
||||
import org.bukkit.event.Listener
|
||||
@@ -106,7 +110,8 @@ class ActionBarHandler(
|
||||
plugin.configYml
|
||||
.getFormattedString(
|
||||
"persistent-action-bar.format", placeholderContext(
|
||||
player = player
|
||||
player = player,
|
||||
injectable = PlayerHealthInjectable
|
||||
)
|
||||
)
|
||||
)
|
||||
@@ -119,4 +124,27 @@ class ActionBarHandler(
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private object PlayerHealthInjectable : PlaceholderInjectable {
|
||||
private val injections = listOf(
|
||||
PlayerStaticPlaceholder(
|
||||
"health"
|
||||
) { it.health.toInt().toString() },
|
||||
PlayerStaticPlaceholder(
|
||||
"max_health"
|
||||
) { it.getAttribute(Attribute.GENERIC_MAX_HEALTH)?.value?.toInt()?.toString() ?: "20" },
|
||||
)
|
||||
|
||||
override fun getPlaceholderInjections(): List<InjectablePlaceholder> {
|
||||
return injections
|
||||
}
|
||||
|
||||
override fun addInjectablePlaceholder(p0: Iterable<InjectablePlaceholder>) {
|
||||
return
|
||||
}
|
||||
|
||||
override fun clearInjectedPlaceholders() {
|
||||
return
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -249,10 +249,10 @@ persistent-action-bar:
|
||||
# If a player's health should be scaled to always display as 10 hearts.
|
||||
scale-health: true
|
||||
# The format
|
||||
format: "&c❤ &f%player_health_rounded%&8/&f%player_max_health_rounded% &#e884b0🛡 &f%ecoskills_defense% &8| &#db0000🗡 &f%ecoskills_strength% &8| (ffe6✦ &f%ecoskills_speed%"
|
||||
format: "&c❤ &f%health%&8/&f%max_health% &#e884b0🛡 &f%ecoskills_defense% &8| &#db0000🗡 &f%ecoskills_strength% &8| (ffe6✦ &f%ecoskills_speed%"
|
||||
|
||||
# Optional format if mana is being used.
|
||||
# format: "&c❤ &f%player_health_rounded%&8/&f%player_max_health_rounded% &f%ecoskills_mana%&8/&f%ecoskills_mana_limit% (ffe6🌊"
|
||||
# format: "&c❤ &f%health%&8/&f%max_health% &f%ecoskills_mana%&8/&f%ecoskills_mana_limit% (ffe6🌊"
|
||||
|
||||
# The worlds that the action bar should be disabled in.
|
||||
disabled-in-worlds: [ ]
|
||||
|
||||
Reference in New Issue
Block a user