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 ea563e8b..ff4938e4 100644 --- a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/EcoEnchants.java +++ b/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/EcoEnchants.java @@ -217,6 +217,8 @@ public class EcoEnchants { public static final EcoEnchant DISABLE = new Disable(); public static final EcoEnchant HELLISH = new Hellish(); public static final EcoEnchant VOID_AFFINITY = new VoidAffinity(); + public static final EcoEnchant CUBISM = new Cubism(); + public static final EcoEnchant QUADRILATERALISM = new Quadrilateralism(); /** * Get all registered {@link EcoEnchant}s diff --git a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Cubism.java b/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Cubism.java new file mode 100644 index 00000000..1d328801 --- /dev/null +++ b/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Cubism.java @@ -0,0 +1,42 @@ +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 org.bukkit.entity.*; +import org.bukkit.event.EventHandler; +import org.bukkit.event.entity.EntityDamageByEntityEvent; + +public class Cubism extends EcoEnchant { + public Cubism() { + super( + new EcoEnchantBuilder("cubism", EnchantmentType.NORMAL, new Target.Applicable[]{Target.Applicable.SWORD, Target.Applicable.AXE}, 4.0) + ); + } + + // START OF LISTENERS + + @EventHandler + public void onDamage(EntityDamageByEntityEvent event) { + if (!(event.getDamager() instanceof Player)) return; + + if (!(event.getEntity() instanceof LivingEntity)) return; + + Player player = (Player) event.getDamager(); + LivingEntity victim = (LivingEntity) event.getEntity(); + + if(!(victim instanceof Slime)) + return; + + if (!EnchantChecks.mainhand(player, this)) return; + int level = EnchantChecks.getMainhandLevel(player, this); + + double multiplier = this.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "multiplier"); + + double damageMultiplier = (level * multiplier) + 1; + + event.setDamage(event.getDamage() * damageMultiplier); + } +} \ No newline at end of file diff --git a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Quadrilateralism.java b/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Quadrilateralism.java new file mode 100644 index 00000000..226070fb --- /dev/null +++ b/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/normal/Quadrilateralism.java @@ -0,0 +1,45 @@ +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 org.bukkit.entity.*; +import org.bukkit.event.EventHandler; +import org.bukkit.event.entity.EntityDamageByEntityEvent; + +public class Quadrilateralism extends EcoEnchant { + public Quadrilateralism() { + super( + new EcoEnchantBuilder("quadrilateralism", EnchantmentType.NORMAL, new Target.Applicable[]{Target.Applicable.BOW, Target.Applicable.CROSSBOW}, 4.0) + ); + } + + // START OF LISTENERS + + @EventHandler + public void onDamage(EntityDamageByEntityEvent event) { + if (!(event.getDamager() instanceof Arrow)) return; + + if (!(((Arrow) event.getDamager()).getShooter() instanceof Player)) return; + + if (!(event.getEntity() instanceof LivingEntity)) return; + + Player player = (Player) ((Arrow) event.getDamager()).getShooter(); + Arrow arrow = (Arrow) event.getDamager(); + LivingEntity victim = (LivingEntity) event.getEntity(); + + if(!(victim instanceof Slime)) + return; + + if (!EnchantChecks.arrow(arrow, this)) return; + int level = EnchantChecks.getArrowLevel(arrow, this); + + double multiplier = this.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "multiplier"); + + double damageMultiplier = (level * multiplier) + 1; + + event.setDamage(event.getDamage() * damageMultiplier); + } +} \ No newline at end of file diff --git a/Plugin/src/main/resources/enchants/normal/cubism.yml b/Plugin/src/main/resources/enchants/normal/cubism.yml new file mode 100644 index 00000000..507fa40d --- /dev/null +++ b/Plugin/src/main/resources/enchants/normal/cubism.yml @@ -0,0 +1,23 @@ +# +# Cubism EcoEnchant +# + +config-version: 4.0 # Don't edit this. + +name: "Cubism" + +description: Increases damage dealt against slimes and magma cubes. + +obtaining: + table: true + villager: true + loot: true + rarity: rare + +general-config: + grindstoneable: true + conflicts: [] + maximum-level: 5 + +config: + multiplier: 0.1 # Damage = level * multiplier + 1 \ No newline at end of file diff --git a/Plugin/src/main/resources/enchants/normal/quadrilateralism.yml b/Plugin/src/main/resources/enchants/normal/quadrilateralism.yml new file mode 100644 index 00000000..7345f94d --- /dev/null +++ b/Plugin/src/main/resources/enchants/normal/quadrilateralism.yml @@ -0,0 +1,23 @@ +# +# Quadrilateralism EcoEnchant +# + +config-version: 4.0 # Don't edit this. + +name: "Quadrilateralism" + +description: Increases damage dealt against slimes and magma cubes. + +obtaining: + table: true + villager: true + loot: true + rarity: rare + +general-config: + grindstoneable: true + conflicts: [] + maximum-level: 5 + +config: + multiplier: 0.1 # Damage = level * multiplier + 1 \ No newline at end of file diff --git a/Plugin/src/main/resources/plugin.yml b/Plugin/src/main/resources/plugin.yml index 198962b1..7e78fe55 100644 --- a/Plugin/src/main/resources/plugin.yml +++ b/Plugin/src/main/resources/plugin.yml @@ -236,6 +236,8 @@ permissions: ecoenchants.fromtable.disable: true ecoenchants.fromtable.hellish: true ecoenchants.fromtable.voidaffinity: true + ecoenchants.fromtable.cubism: true + ecoenchants.fromtable.quadrilateralism: true ecoenchants.updateannounce: description: Informs admins of a new update @@ -816,4 +818,10 @@ permissions: default: true ecoenchants.fromtable.voidaffinity: description: Allows getting void affinity from an enchanting table + default: true + ecoenchants.fromtable.cubism: + description: Allows getting cubism from an enchanting table + default: true + ecoenchants.fromtable.quadrilateralism: + description: Allows getting quadrilateralism from an enchanting table default: true \ No newline at end of file