mirror of
https://github.com/Auxilor/EcoSkills.git
synced 2025-12-31 04:46:31 +00:00
Added health stat (unused by default)
This commit is contained in:
@@ -6,6 +6,7 @@ import com.willfp.ecoskills.stats.stats.StatCritChance;
|
||||
import com.willfp.ecoskills.stats.stats.StatCritDamage;
|
||||
import com.willfp.ecoskills.stats.stats.StatDefense;
|
||||
import com.willfp.ecoskills.stats.stats.StatFerocity;
|
||||
import com.willfp.ecoskills.stats.stats.StatHealth;
|
||||
import com.willfp.ecoskills.stats.stats.StatSpeed;
|
||||
import com.willfp.ecoskills.stats.stats.StatStrength;
|
||||
import com.willfp.ecoskills.stats.stats.StatWisdom;
|
||||
@@ -31,6 +32,7 @@ public class Stats {
|
||||
public static final Stat SPEED = new StatSpeed();
|
||||
public static final Stat WISDOM = new StatWisdom();
|
||||
public static final Stat FEROCITY = new StatFerocity();
|
||||
public static final Stat HEALTH = new StatHealth();
|
||||
|
||||
@ApiStatus.Internal
|
||||
public static void registerNewStat(@NotNull final Stat skill) {
|
||||
|
||||
@@ -0,0 +1,44 @@
|
||||
package com.willfp.ecoskills.stats.stats
|
||||
|
||||
import com.willfp.ecoskills.getStatLevel
|
||||
import com.willfp.ecoskills.stats.Stat
|
||||
import org.bukkit.attribute.Attribute
|
||||
import org.bukkit.attribute.AttributeModifier
|
||||
import org.bukkit.entity.Player
|
||||
import org.bukkit.event.EventHandler
|
||||
import org.bukkit.event.EventPriority
|
||||
import org.bukkit.event.player.PlayerChangedWorldEvent
|
||||
|
||||
class StatHealth : Stat(
|
||||
"health"
|
||||
) {
|
||||
override fun updateStatLevel(player: Player) {
|
||||
val modifier = AttributeModifier(
|
||||
this.uuid,
|
||||
this.name,
|
||||
this.config.getDouble("health-per-level") * player.getStatLevel(this),
|
||||
AttributeModifier.Operation.MULTIPLY_SCALAR_1
|
||||
)
|
||||
val instance = player.getAttribute(Attribute.GENERIC_MAX_HEALTH) ?: return
|
||||
|
||||
instance.removeModifier(modifier)
|
||||
|
||||
if (this.config.getStrings("disabled-in-worlds").contains(player.world.name)) {
|
||||
return
|
||||
}
|
||||
|
||||
plugin.scheduler.run {
|
||||
instance.removeModifier(modifier)
|
||||
instance.addModifier(modifier)
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.LOW)
|
||||
fun handle(event: PlayerChangedWorldEvent) {
|
||||
val player = event.player
|
||||
|
||||
plugin.scheduler.run {
|
||||
updateStatLevel(player)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -324,6 +324,12 @@ stats:
|
||||
disabled-in-worlds: []
|
||||
# The percent chance to deal damage twice
|
||||
chance-per-level: 0.5
|
||||
health:
|
||||
name: "&c❤ Health"
|
||||
# Disabled worlds
|
||||
disabled-in-worlds: []
|
||||
# The extra hp per level
|
||||
health-per-level: 1
|
||||
|
||||
damage-indicators:
|
||||
# Requires HolographicDisplays/GHolo/CMI to be installed
|
||||
|
||||
Reference in New Issue
Block a user