diff --git a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/EcoEnchants.java b/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/EcoEnchants.java index 2b4dbc30..747782c9 100644 --- a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/EcoEnchants.java +++ b/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/EcoEnchants.java @@ -201,6 +201,7 @@ public class EcoEnchants { public static final EcoEnchant NETHERIC = new Netheric(); public static final EcoEnchant ENDERISM = new Enderism(); public static final EcoEnchant RAGE = new Rage(); + public static final EcoEnchant IMPACT = new Impact(); /** * Get all registered {@link EcoEnchant}s diff --git a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Impact.java b/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Impact.java new file mode 100644 index 00000000..8e59a0f5 --- /dev/null +++ b/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Impact.java @@ -0,0 +1,53 @@ +package com.willfp.ecoenchants.enchantments.ecoenchants.normal; + +import com.willfp.ecoenchants.enchantments.EcoEnchant; +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.nms.TridentStack; +import com.willfp.ecoenchants.util.Rand; +import org.bukkit.entity.LivingEntity; +import org.bukkit.entity.Player; +import org.bukkit.entity.Trident; +import org.bukkit.event.EventHandler; +import org.bukkit.event.entity.EntityDamageByEntityEvent; +import org.bukkit.inventory.ItemStack; + +public class Impact extends EcoEnchant { + public Impact() { + super( + new EcoEnchantBuilder("impact", EnchantmentType.NORMAL, Target.Applicable.TRIDENT, 4.0) + ); + } + + // START OF LISTENERS + + @EventHandler + public void onHit(EntityDamageByEntityEvent event) { + if (!(event.getDamager() instanceof Trident)) + return; + + if(!(((Trident) event.getDamager()).getShooter() instanceof Player)) + return; + + if (!(event.getEntity() instanceof LivingEntity)) + return; + + if (event.isCancelled()) + return; + + Player player = (Player) ((Trident) event.getDamager()).getShooter(); + Trident trident = (Trident) event.getDamager(); + ItemStack item = TridentStack.getTridentStack(trident); + + 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; + + event.setDamage(event.getDamage() * this.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "damage-multiplier")); + } +} diff --git a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Supercritical.java b/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Supercritical.java index 94ff7e61..dd5f58e0 100644 --- a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Supercritical.java +++ b/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Supercritical.java @@ -34,9 +34,6 @@ public class Supercritical extends EcoEnchant { if (!EnchantChecks.mainhand(player, this)) return; - if (!(((LivingEntity) event.getEntity()).getHealth() == ((LivingEntity) event.getEntity()).getAttribute(Attribute.GENERIC_MAX_HEALTH).getValue())) - return; - if (Cooldown.getCooldown(player) != 1.0f && !this.getConfig().getBool(EcoEnchants.CONFIG_LOCATION + "allow-not-fully-charged")) return; diff --git a/Plugin/src/main/resources/enchants/normal/impact.yml b/Plugin/src/main/resources/enchants/normal/impact.yml new file mode 100644 index 00000000..14cb9fe6 --- /dev/null +++ b/Plugin/src/main/resources/enchants/normal/impact.yml @@ -0,0 +1,24 @@ +# +# Impact EcoEnchant +# + +config-version: 4.0 # Don't edit this. + +name: "Impact" + +description: Small chance to deal extreme damage. + +obtaining: + table: true + villager: true + loot: true + rarity: legendary + +general-config: + grindstoneable: true + conflicts: [] + maximum-level: 3 + +config: + damage-multiplier: 3 + chance-per-level: 0.5 # Chance to deal more (as percentage) \ No newline at end of file diff --git a/Plugin/src/main/resources/plugin.yml b/Plugin/src/main/resources/plugin.yml index 9e78bb05..329f4511 100644 --- a/Plugin/src/main/resources/plugin.yml +++ b/Plugin/src/main/resources/plugin.yml @@ -220,6 +220,7 @@ permissions: ecoenchants.fromtable.netheric: true ecoenchants.fromtable.enderism: true ecoenchants.fromtable.rage: true + ecoenchants.fromtable.impact: true ecoenchants.updateannounce: description: Informs admins of a new update @@ -752,4 +753,7 @@ permissions: default: true ecoenchants.fromtable.rage: description: Allows getting rage from an enchanting table + default: true + ecoenchants.fromtable.impact: + description: Allows getting impact from an enchanting table default: true \ No newline at end of file