From 966ab49af1cb8d15d704e433a93ad857998238f2 Mon Sep 17 00:00:00 2001 From: _OfTeN_ Date: Wed, 8 Sep 2021 18:47:30 +0300 Subject: [PATCH] Added disable-on-players option for Razor, Bladed and Force enchantments --- .../ecoenchants/enchantments/ecoenchants/special/Bladed.java | 2 ++ .../ecoenchants/enchantments/ecoenchants/special/Force.java | 2 ++ .../ecoenchants/enchantments/ecoenchants/special/Razor.java | 1 + .../core-plugin/src/main/resources/enchants/special/bladed.yml | 1 + .../core-plugin/src/main/resources/enchants/special/force.yml | 1 + .../core-plugin/src/main/resources/enchants/special/razor.yml | 1 + 6 files changed, 8 insertions(+) diff --git a/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/special/Bladed.java b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/special/Bladed.java index 4ad1a095..83341309 100644 --- a/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/special/Bladed.java +++ b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/special/Bladed.java @@ -4,6 +4,7 @@ import com.willfp.ecoenchants.enchantments.EcoEnchant; import com.willfp.ecoenchants.enchantments.EcoEnchants; import com.willfp.ecoenchants.enchantments.meta.EnchantmentType; import org.bukkit.entity.LivingEntity; +import org.bukkit.entity.Player; import org.bukkit.entity.Trident; import org.bukkit.event.entity.EntityDamageByEntityEvent; import org.jetbrains.annotations.NotNull; @@ -21,6 +22,7 @@ public class Bladed extends EcoEnchant { @NotNull final Trident trident, final int level, @NotNull final EntityDamageByEntityEvent event) { + if (victim instanceof Player && this.getConfig().getBool(EcoEnchants.CONFIG_LOCATION + "disable-on-players")) return; double baseDamage = this.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "base-multiplier"); double damage = event.getDamage(); double multiplier = this.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "multiplier"); diff --git a/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/special/Force.java b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/special/Force.java index e92ee028..099adbbe 100644 --- a/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/special/Force.java +++ b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/special/Force.java @@ -5,6 +5,7 @@ import com.willfp.ecoenchants.enchantments.EcoEnchants; import com.willfp.ecoenchants.enchantments.meta.EnchantmentType; import org.bukkit.entity.Arrow; import org.bukkit.entity.LivingEntity; +import org.bukkit.entity.Player; import org.bukkit.event.entity.EntityDamageByEntityEvent; import org.jetbrains.annotations.NotNull; @@ -21,6 +22,7 @@ public class Force extends EcoEnchant { @NotNull final Arrow arrow, final int level, @NotNull final EntityDamageByEntityEvent event) { + if (victim instanceof Player && this.getConfig().getBool(EcoEnchants.CONFIG_LOCATION + "disable-on-players")) return; double damage = event.getDamage(); double multiplier = this.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "multiplier"); double bonus = (multiplier * (level + 6)) + 1; diff --git a/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/special/Razor.java b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/special/Razor.java index bef73e33..ec92ace3 100644 --- a/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/special/Razor.java +++ b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/special/Razor.java @@ -20,6 +20,7 @@ public class Razor extends EcoEnchant { @NotNull final LivingEntity victim, final int level, @NotNull final EntityDamageByEntityEvent event) { + if (victim instanceof Player && this.getConfig().getBool(EcoEnchants.CONFIG_LOCATION + "disable-on-players")) return; double perLevelMultiplier = this.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "multiplier"); double baseDamage = this.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "base-damage"); double extra = (level * perLevelMultiplier) + baseDamage; diff --git a/eco-core/core-plugin/src/main/resources/enchants/special/bladed.yml b/eco-core/core-plugin/src/main/resources/enchants/special/bladed.yml index f199eba3..a657fac4 100644 --- a/eco-core/core-plugin/src/main/resources/enchants/special/bladed.yml +++ b/eco-core/core-plugin/src/main/resources/enchants/special/bladed.yml @@ -31,6 +31,7 @@ general-config: maximum-level: 5 config: + disable-on-players: false # Should this enchantment only boost damage on mobs base-multiplier: 1.5 # Percent more damage to do as base multiplier: 0.5 # 1 + (Level * Multiplier) is multiplied with the damage # To explain, Bladed V would be 4x more damage: 1.5 + (5*0.5) diff --git a/eco-core/core-plugin/src/main/resources/enchants/special/force.yml b/eco-core/core-plugin/src/main/resources/enchants/special/force.yml index 516d905e..9049a13f 100644 --- a/eco-core/core-plugin/src/main/resources/enchants/special/force.yml +++ b/eco-core/core-plugin/src/main/resources/enchants/special/force.yml @@ -30,4 +30,5 @@ general-config: maximum-level: 8 config: + disable-on-players: false # Should this enchantment only boost damage on mobs multiplier: 0.25 # Formula is (multiplier * (level + 6) + 1)*damage | Default functions as power 5 + level, eg force 2 = power 7 \ No newline at end of file diff --git a/eco-core/core-plugin/src/main/resources/enchants/special/razor.yml b/eco-core/core-plugin/src/main/resources/enchants/special/razor.yml index ce353329..a3037d16 100644 --- a/eco-core/core-plugin/src/main/resources/enchants/special/razor.yml +++ b/eco-core/core-plugin/src/main/resources/enchants/special/razor.yml @@ -32,6 +32,7 @@ general-config: maximum-level: 8 config: + disable-on-players: false # Should this enchantment only boost damage on mobs multiplier: 0.3 # Vanilla sharpness is 0.5*level + 0.5 extra damage. Razor formula is multiplier*level + base extra damage. base-damage: 10 # Vanilla Smite 5/BOA 5 extra damage is 12.5 decrease-if-cooldown: true \ No newline at end of file