Added Force
This commit is contained in:
@@ -188,6 +188,7 @@ public class EcoEnchants {
|
||||
public static final EcoEnchant DIVERSE = new Diverse();
|
||||
public static final EcoEnchant LIFE_STEAL = new LifeSteal();
|
||||
public static final EcoEnchant LIME_ARTIFACT = new LimeArtifact();
|
||||
public static final EcoEnchant FORCE = new Force();
|
||||
|
||||
/**
|
||||
* Get all registered {@link EcoEnchant}s
|
||||
|
||||
@@ -0,0 +1,47 @@
|
||||
package com.willfp.ecoenchants.enchantments.ecoenchants.special;
|
||||
|
||||
import com.comphenix.protocol.PacketType;
|
||||
import com.willfp.ecoenchants.EcoEnchantsPlugin;
|
||||
import com.willfp.ecoenchants.enchantments.EcoEnchant;
|
||||
import com.willfp.ecoenchants.enchantments.EcoEnchantBuilder;
|
||||
import com.willfp.ecoenchants.enchantments.EcoEnchants;
|
||||
import com.willfp.ecoenchants.nms.Target;
|
||||
import com.willfp.ecoenchants.util.HasEnchant;
|
||||
import org.bukkit.entity.Arrow;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.entity.EntityDamageByEntityEvent;
|
||||
import org.bukkit.event.entity.ProjectileLaunchEvent;
|
||||
import org.bukkit.metadata.FixedMetadataValue;
|
||||
|
||||
public class Force extends EcoEnchant {
|
||||
public Force() {
|
||||
super(
|
||||
new EcoEnchantBuilder("force", EnchantmentType.SPECIAL, Target.Applicable.BOW, 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;
|
||||
|
||||
Player player = (Player) ((Arrow) event.getDamager()).getShooter();
|
||||
|
||||
if(!HasEnchant.playerHeld(player, this))
|
||||
return;
|
||||
|
||||
int level = HasEnchant.getPlayerLevel(player, this);
|
||||
|
||||
double damage = event.getDamage();
|
||||
double multiplier = this.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "multiplier");
|
||||
double bonus = (multiplier * (level + 6)) + 1;
|
||||
event.setDamage(damage * bonus);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user