Added disable
This commit is contained in:
@@ -214,6 +214,7 @@ public class EcoEnchants {
|
||||
public static final EcoEnchant ARACHNID = new Arachnid();
|
||||
public static final EcoEnchant PACIFY = new Pacify();
|
||||
public static final EcoEnchant ABATTOIR = new Abattoir();
|
||||
public static final EcoEnchant DISABLE = new Disable();
|
||||
|
||||
/**
|
||||
* Get all registered {@link EcoEnchant}s
|
||||
|
||||
@@ -0,0 +1,52 @@
|
||||
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.integrations.antigrief.AntigriefManager;
|
||||
import com.willfp.ecoenchants.nms.Cooldown;
|
||||
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;
|
||||
import org.bukkit.event.entity.EntityDamageByEntityEvent;
|
||||
import org.bukkit.potion.PotionEffect;
|
||||
import org.bukkit.potion.PotionEffectType;
|
||||
|
||||
public class Disable extends EcoEnchant {
|
||||
public Disable() {
|
||||
super(
|
||||
new EcoEnchantBuilder("disable", EnchantmentType.NORMAL, Target.Applicable.AXE, 4.0)
|
||||
);
|
||||
}
|
||||
|
||||
// START OF LISTENERS
|
||||
|
||||
@EventHandler
|
||||
public void onHit(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(!AntigriefManager.canInjure(player, victim)) return;
|
||||
|
||||
if (!EnchantChecks.mainhand(player, this)) return;
|
||||
|
||||
if (Cooldown.getCooldown(player) != 1.0f && !this.getConfig().getBool(EcoEnchants.CONFIG_LOCATION + "allow-not-fully-charged"))
|
||||
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;
|
||||
|
||||
victim.addPotionEffect(new PotionEffect(PotionEffectType.SLOW_DIGGING, level * 10, 5));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user