diff --git a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/spell/Missile.java b/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/spell/Missile.java index 9bdf0aeb..9a73c278 100644 --- a/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/spell/Missile.java +++ b/Plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/spell/Missile.java @@ -1,9 +1,14 @@ package com.willfp.ecoenchants.enchantments.ecoenchants.spell; +import com.willfp.ecoenchants.EcoEnchantsPlugin; import com.willfp.ecoenchants.enchantments.EcoEnchants; import com.willfp.ecoenchants.enchantments.itemtypes.Spell; import org.bukkit.entity.Player; import org.bukkit.entity.WitherSkull; +import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; +import org.bukkit.event.entity.EntityDamageByEntityEvent; +import org.bukkit.metadata.FixedMetadataValue; public class Missile extends Spell { public Missile() { @@ -15,7 +20,17 @@ public class Missile extends Spell { WitherSkull skull = player.launchProjectile(WitherSkull.class, player.getEyeLocation().getDirection().multiply(this.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "velocity"))); skull.setCharged(true); skull.setIsIncendiary(false); - skull.setYield((float) this.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "power")); + skull.setMetadata("eco-damage", new FixedMetadataValue(EcoEnchantsPlugin.getInstance(), this.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "damage-per-level") * level)); skull.setShooter(player); } + + @EventHandler(priority = EventPriority.LOW) + public void onWitherSkullDamage(EntityDamageByEntityEvent event) { + if(!(event.getDamager() instanceof WitherSkull)) return; + if(event.getDamager().getMetadata("eco-damage").isEmpty()) return; + + double multiplier = event.getDamager().getMetadata("eco-damage").get(0).asDouble(); + + event.setDamage(multiplier); + } } diff --git a/Plugin/src/main/resources/enchants/spell/missile.yml b/Plugin/src/main/resources/enchants/spell/missile.yml index 295de8c3..cc005d64 100644 --- a/Plugin/src/main/resources/enchants/spell/missile.yml +++ b/Plugin/src/main/resources/enchants/spell/missile.yml @@ -23,4 +23,4 @@ general-config: config: cooldown: 20 # In seconds velocity: 3 - power: 5 \ No newline at end of file + damage-per-level: 8 \ No newline at end of file