From 979bb8c9b85edc8b1452046eac5dcef2e1a1ba0c Mon Sep 17 00:00:00 2001 From: Auxilor Date: Sun, 30 Aug 2020 14:47:03 +0100 Subject: [PATCH] Added chance to conclude, finality, and finishing --- .../enchantments/ecoenchants/normal/Conclude.java | 6 +++++- .../enchantments/ecoenchants/normal/Finality.java | 6 +++++- .../enchantments/ecoenchants/normal/Finishing.java | 6 +++++- Plugin/src/main/resources/enchants/normal/conclude.yml | 7 ++++--- Plugin/src/main/resources/enchants/normal/finality.yml | 7 ++++--- Plugin/src/main/resources/enchants/normal/finishing.yml | 7 ++++--- Plugin/src/main/resources/enchants/normal/sycophant.yml | 4 ++-- 7 files changed, 29 insertions(+), 14 deletions(-) diff --git a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Conclude.java b/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Conclude.java index 3dda0272..cc58b4ab 100644 --- a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Conclude.java +++ b/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Conclude.java @@ -6,6 +6,7 @@ import com.willfp.ecoenchants.enchantments.EcoEnchants; import com.willfp.ecoenchants.enchantments.util.checks.EnchantChecks; import com.willfp.ecoenchants.nms.Target; import com.willfp.ecoenchants.nms.TridentStack; +import com.willfp.ecoenchants.util.Rand; import org.bukkit.entity.Arrow; import org.bukkit.entity.LivingEntity; import org.bukkit.entity.Player; @@ -17,7 +18,7 @@ import org.bukkit.inventory.ItemStack; public class Conclude extends EcoEnchant { public Conclude() { super( - new EcoEnchantBuilder("conclude", EnchantmentType.NORMAL, Target.Applicable.TRIDENT, 4.0) + new EcoEnchantBuilder("conclude", EnchantmentType.NORMAL, Target.Applicable.TRIDENT, 4.1) ); } @@ -37,6 +38,9 @@ public class Conclude extends EcoEnchant { if (!EnchantChecks.item(item, this)) return; int level = EnchantChecks.getItemLevel(item, this); + if (Rand.randFloat(0, 1) > level * 0.01 * this.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "chance-per-level")) + return; + double minhealth = this.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "minimum-health-per-level"); if (!(victim.getHealth() <= level * minhealth)) return; diff --git a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Finality.java b/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Finality.java index 8622cd35..796cfdb3 100644 --- a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Finality.java +++ b/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Finality.java @@ -5,6 +5,7 @@ import com.willfp.ecoenchants.enchantments.EcoEnchantBuilder; import com.willfp.ecoenchants.enchantments.EcoEnchants; import com.willfp.ecoenchants.enchantments.util.checks.EnchantChecks; import com.willfp.ecoenchants.nms.Target; +import com.willfp.ecoenchants.util.Rand; import org.bukkit.entity.Arrow; import org.bukkit.entity.LivingEntity; import org.bukkit.entity.Player; @@ -14,7 +15,7 @@ import org.bukkit.event.entity.EntityDamageByEntityEvent; public class Finality extends EcoEnchant { public Finality() { super( - new EcoEnchantBuilder("finality", EnchantmentType.NORMAL, Target.Applicable.BOW, 4.0) + new EcoEnchantBuilder("finality", EnchantmentType.NORMAL, Target.Applicable.BOW, 4.1) ); } @@ -36,6 +37,9 @@ public class Finality extends EcoEnchant { if (!EnchantChecks.arrow(arrow, this)) return; int level = EnchantChecks.getArrowLevel(arrow, this); + if (Rand.randFloat(0, 1) > level * 0.01 * this.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "chance-per-level")) + return; + double minhealth = this.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "minimum-health-per-level"); if (!(((LivingEntity) event.getEntity()).getHealth() <= level * minhealth)) return; diff --git a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Finishing.java b/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Finishing.java index 2e515ca8..ab6d6753 100644 --- a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Finishing.java +++ b/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Finishing.java @@ -5,6 +5,7 @@ import com.willfp.ecoenchants.enchantments.EcoEnchantBuilder; import com.willfp.ecoenchants.enchantments.EcoEnchants; import com.willfp.ecoenchants.enchantments.util.checks.EnchantChecks; import com.willfp.ecoenchants.nms.Target; +import com.willfp.ecoenchants.util.Rand; import org.bukkit.entity.LivingEntity; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; @@ -12,7 +13,7 @@ import org.bukkit.event.entity.EntityDamageByEntityEvent; public class Finishing extends EcoEnchant { public Finishing() { super( - new EcoEnchantBuilder("finishing", EnchantmentType.NORMAL, Target.Applicable.SWORD, 4.0) + new EcoEnchantBuilder("finishing", EnchantmentType.NORMAL, Target.Applicable.SWORD, 4.1) ); } @@ -32,6 +33,9 @@ public class Finishing extends EcoEnchant { if (!EnchantChecks.mainhand(player, this)) return; int level = EnchantChecks.getMainhandLevel(player, this); + if (Rand.randFloat(0, 1) > level * 0.01 * this.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "chance-per-level")) + return; + double minhealth = this.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "minimum-health-per-level"); if (!(((LivingEntity) event.getEntity()).getHealth() <= level * minhealth)) return; diff --git a/Plugin/src/main/resources/enchants/normal/conclude.yml b/Plugin/src/main/resources/enchants/normal/conclude.yml index 1d144db2..d96ccd9b 100644 --- a/Plugin/src/main/resources/enchants/normal/conclude.yml +++ b/Plugin/src/main/resources/enchants/normal/conclude.yml @@ -2,11 +2,11 @@ # Conclude EcoEnchant # -config-version: 4.0 # Don't edit this. +config-version: 4.1 # Don't edit this. name: "Conclude" -description: Instantly kill entities on low health. +description: Chance to instantly kill entities on low health. obtaining: table: true @@ -20,4 +20,5 @@ general-config: maximum-level: 5 config: - minimum-health-per-level: 1 # Multiplied by level, eg: if 1, then Conclude 5 kills any mobs below 2.5 hearts \ No newline at end of file + minimum-health-per-level: 1 # Multiplied by level, eg: if 1, then Conclude 5 kills any mobs below 2.5 hearts + chance-per-level: 10 \ No newline at end of file diff --git a/Plugin/src/main/resources/enchants/normal/finality.yml b/Plugin/src/main/resources/enchants/normal/finality.yml index 6cf26c90..f38a0cd4 100644 --- a/Plugin/src/main/resources/enchants/normal/finality.yml +++ b/Plugin/src/main/resources/enchants/normal/finality.yml @@ -2,11 +2,11 @@ # Finality EcoEnchant # -config-version: 4.0 # Don't edit this. +config-version: 4.1 # Don't edit this. name: "Finality" -description: Instantly kill entities on low health. +description: Chance to instantly kill entities on low health. obtaining: table: true @@ -20,4 +20,5 @@ general-config: maximum-level: 5 config: - minimum-health-per-level: 1 # Multiplied by level, eg: if 1, then Finality 5 kills any mobs below 2.5 hearts \ No newline at end of file + minimum-health-per-level: 1 # Multiplied by level, eg: if 1, then Finality 5 kills any mobs below 2.5 hearts + chance-per-level: 10 \ No newline at end of file diff --git a/Plugin/src/main/resources/enchants/normal/finishing.yml b/Plugin/src/main/resources/enchants/normal/finishing.yml index a01a6331..ba55c88c 100644 --- a/Plugin/src/main/resources/enchants/normal/finishing.yml +++ b/Plugin/src/main/resources/enchants/normal/finishing.yml @@ -2,11 +2,11 @@ # Finishing EcoEnchant # -config-version: 4.0 # Don't edit this. +config-version: 4.1 # Don't edit this. name: "Finishing" -description: Instantly kill entities on low health. +description: Chance to instantly kill entities on low health. obtaining: table: true @@ -20,4 +20,5 @@ general-config: maximum-level: 5 config: - minimum-health-per-level: 1 # Multiplied by level, eg: if 1, then Finishing 5 kills any mobs below 2.5 hearts \ No newline at end of file + minimum-health-per-level: 1 # Multiplied by level, eg: if 1, then Finishing 5 kills any mobs below 2.5 hearts + chance-per-level: 10 \ No newline at end of file diff --git a/Plugin/src/main/resources/enchants/normal/sycophant.yml b/Plugin/src/main/resources/enchants/normal/sycophant.yml index e72f0ff9..361ca9d7 100644 --- a/Plugin/src/main/resources/enchants/normal/sycophant.yml +++ b/Plugin/src/main/resources/enchants/normal/sycophant.yml @@ -17,7 +17,7 @@ obtaining: general-config: grindstoneable: true conflicts: [] - maximum-level: 3 + maximum-level: 6 config: - damage-multiplier-per-level: 0.08 # Damage * Level * Multiplier is used to calculate how much health to heal + damage-multiplier-per-level: 0.04 # Damage * Level * Multiplier is used to calculate how much health to heal