diff --git a/eco-core/core-plugin/src/main/java/com/willfp/ecoskills/stats/Stats.java b/eco-core/core-plugin/src/main/java/com/willfp/ecoskills/stats/Stats.java index a0ecc77..8d74446 100644 --- a/eco-core/core-plugin/src/main/java/com/willfp/ecoskills/stats/Stats.java +++ b/eco-core/core-plugin/src/main/java/com/willfp/ecoskills/stats/Stats.java @@ -5,6 +5,7 @@ import com.willfp.eco.core.config.updating.ConfigUpdater; 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.StatSpeed; import com.willfp.ecoskills.stats.stats.StatStrength; import com.willfp.ecoskills.stats.stats.StatWisdom; @@ -29,6 +30,7 @@ public class Stats { public static final Stat CRIT_DAMAGE = new StatCritDamage(); public static final Stat SPEED = new StatSpeed(); public static final Stat WISDOM = new StatWisdom(); + public static final Stat FEROCITY = new StatFerocity(); @ApiStatus.Internal public static void registerNewStat(@NotNull final Stat skill) { diff --git a/eco-core/core-plugin/src/main/kotlin/com/willfp/ecoskills/stats/stats/StatFerocity.kt b/eco-core/core-plugin/src/main/kotlin/com/willfp/ecoskills/stats/stats/StatFerocity.kt new file mode 100644 index 0000000..58e6feb --- /dev/null +++ b/eco-core/core-plugin/src/main/kotlin/com/willfp/ecoskills/stats/stats/StatFerocity.kt @@ -0,0 +1,51 @@ +package com.willfp.ecoskills.stats.stats + +import com.willfp.eco.util.NumberUtils +import com.willfp.ecoskills.getStatLevel +import com.willfp.ecoskills.isCrit +import com.willfp.ecoskills.stats.Stat +import com.willfp.ecoskills.stats.Stats +import org.bukkit.entity.LivingEntity +import org.bukkit.entity.Player +import org.bukkit.entity.Projectile +import org.bukkit.event.EventHandler +import org.bukkit.event.EventPriority +import org.bukkit.event.entity.EntityDamageByEntityEvent + +class StatFerocity : Stat( + "ferocity" +) { + @EventHandler(priority = EventPriority.LOW) + fun handle(event: EntityDamageByEntityEvent) { + var player = event.damager + val victim = event.entity + val entity = event.damager + + if (victim !is LivingEntity) { + return + } + + if (player is Projectile) { + if (player.shooter !is Player) { + return + } else { + player = player.shooter as Player + } + } + + if (player !is Player) { + return + } + + val level = player.getStatLevel(this) + + if (NumberUtils.randFloat(0.0, 100.0) >= this.config.getDouble("chance-per-level") * level) { + return + } + + this.plugin.run { + victim.noDamageTicks = 0 + victim.damage(event.finalDamage, entity) + } + } +} \ No newline at end of file diff --git a/eco-core/core-plugin/src/main/resources/config.yml b/eco-core/core-plugin/src/main/resources/config.yml index 381130a..26f1a2a 100644 --- a/eco-core/core-plugin/src/main/resources/config.yml +++ b/eco-core/core-plugin/src/main/resources/config.yml @@ -296,6 +296,9 @@ stats: wisdom: # The percent more xp to gain from orbs for each level of the stat. percent-more-xp-gain: 1 + ferocity: + # The percent chance to deal damage twice + chance-per-level: 0.5 effects: bountiful_harvest: diff --git a/eco-core/core-plugin/src/main/resources/lang.yml b/eco-core/core-plugin/src/main/resources/lang.yml index 302f942..ce9450f 100644 --- a/eco-core/core-plugin/src/main/resources/lang.yml +++ b/eco-core/core-plugin/src/main/resources/lang.yml @@ -29,3 +29,5 @@ stats: name: "(ffe6✦ Speed" wisdom: name: "*f566✎ Wisdom" + ferocity: + name: "b0000⫽ Ferocity" diff --git a/eco-core/core-plugin/src/main/resources/skills/combat.yml b/eco-core/core-plugin/src/main/resources/skills/combat.yml index 6bfdebb..95599c8 100644 --- a/eco-core/core-plugin/src/main/resources/skills/combat.yml +++ b/eco-core/core-plugin/src/main/resources/skills/combat.yml @@ -10,7 +10,7 @@ gui: lore: - "&fImproves Stats:" - "&8» &r%ecoskills_strength_name%" - - "&8» &r%ecoskills_crit_damage_name%" + - "&8» &r%ecoskills_ferocity_name%" - "&f" - "&fEffects:" - "&8» &r&6Serrated Strikes %ecoskills_serrated_strikes_numeral%" @@ -19,21 +19,28 @@ rewards: # The actual rewards to be given rewards: - "strength::2" - - "crit_damage::1" + - "ferocity::1:15:100" - "serrated_strikes::1" # The chat messages to send on level up chat-messages: 1: - " &8» &r&f+2 %ecoskills_strength_name%" - - " &8» &r&f+1 %ecoskills_crit_damage_name%" + - " &8» &r&6Serrated Strikes %ecoskills_serrated_strikes_numeral%" + 15: + - " &8» &r&f+2 %ecoskills_strength_name%" + - " &8» &r&f+1 %ecoskills_ferocity_name%" - " &8» &r&6Serrated Strikes %ecoskills_serrated_strikes_numeral%" # The lore to show in the levels gui progression-lore: 1: - " &8» &r&f+2 %ecoskills_strength_name%" - - " &8» &r&f+1 %ecoskills_crit_damage_name%" + - " &8» &r&f+1 %ecoskills_ferocity_name%" + - " &8» &r&6Serrated Strikes %ecoskills_serrated_strikes_numeral%" + 15: + - " &8» &r&f+2 %ecoskills_strength_name%" + - " &8» &r&f+1 %ecoskills_ferocity_name%" - " &8» &r&6Serrated Strikes %ecoskills_serrated_strikes_numeral%" diff --git a/eco-core/core-plugin/src/main/resources/skills/mining.yml b/eco-core/core-plugin/src/main/resources/skills/mining.yml index 896cca6..4c1f554 100644 --- a/eco-core/core-plugin/src/main/resources/skills/mining.yml +++ b/eco-core/core-plugin/src/main/resources/skills/mining.yml @@ -10,6 +10,7 @@ gui: lore: - "&fImproves Stats:" - "&8» &r%ecoskills_defense_name%" + - "&8» &r%ecoskills_ferocity_name%" - "&f" - "&fEffects:" - "&8» &r&6Versatile Tools %ecoskills_versatile_tools_numeral%" @@ -18,18 +19,27 @@ rewards: # The actual rewards to be given rewards: - "defense::2" + - "ferocity::1:15:100" - "versatile_tools::1" # The chat messages to send on level up chat-messages: 1: - - " &8» &r&f+1 %ecoskills_defense_name%" + - " &8» &r&f+2 %ecoskills_defense_name%" + - " &8» &r&6Versatile Tools %ecoskills_versatile_tools_numeral%" + 15: + - " &8» &r&f+2 %ecoskills_defense_name%" + - " &8» &r&f+1 %ecoskills_ferocity_name%" - " &8» &r&6Versatile Tools %ecoskills_versatile_tools_numeral%" # The lore to show in the levels gui progression-lore: 1: - - " &8» &r&f+1 %ecoskills_defense_name%" + - " &8» &r&f+2 %ecoskills_defense_name%" + - " &8» &r&6Versatile Tools %ecoskills_versatile_tools_numeral%" + 15: + - " &8» &r&f+2 %ecoskills_defense_name%" + - " &8» &r&f+1 %ecoskills_ferocity_name%" - " &8» &r&6Versatile Tools %ecoskills_versatile_tools_numeral%" # The xp rewards for each block type diff --git a/eco-core/core-plugin/src/main/resources/skills/woodcutting.yml b/eco-core/core-plugin/src/main/resources/skills/woodcutting.yml index e392269..a761173 100644 --- a/eco-core/core-plugin/src/main/resources/skills/woodcutting.yml +++ b/eco-core/core-plugin/src/main/resources/skills/woodcutting.yml @@ -10,6 +10,7 @@ gui: lore: - "&fImproves Stats:" - "&8» &r%ecoskills_strength_name%" + - "&8» &r%ecoskills_crit_damage_name%" - "&f" - "&fEffects:" - "&8» &r&6Craftsmanship %ecoskills_craftsmanship_numeral%" @@ -18,6 +19,7 @@ rewards: # The actual rewards to be given rewards: - "strength::2" + - "crit_damage::1" - "craftsmanship::1" # The chat messages to send on level up