mirror of
https://github.com/Auxilor/EcoEnchants.git
synced 2024-12-26 20:27:38 +01:00
Added disable
This commit is contained in:
parent
56addbeac8
commit
6521d78300
@ -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));
|
||||
}
|
||||
}
|
24
Plugin/src/main/resources/enchants/normal/disable.yml
Normal file
24
Plugin/src/main/resources/enchants/normal/disable.yml
Normal file
@ -0,0 +1,24 @@
|
||||
#
|
||||
# Disable EcoEnchant
|
||||
#
|
||||
|
||||
config-version: 4.0 # Don't edit this.
|
||||
|
||||
name: "Disable"
|
||||
|
||||
description: Chance of giving your opponent extreme mining fatigue.
|
||||
|
||||
obtaining:
|
||||
table: true
|
||||
villager: true
|
||||
loot: true
|
||||
rarity: epic
|
||||
|
||||
general-config:
|
||||
grindstoneable: true
|
||||
conflicts: []
|
||||
maximum-level: 3
|
||||
|
||||
config:
|
||||
allow-not-fully-charged: false #require attack to be at full charge
|
||||
chance-per-level: 2 #as percentage
|
@ -233,6 +233,7 @@ permissions:
|
||||
ecoenchants.fromtable.arachnid: true
|
||||
ecoenchants.fromtable.pacify: true
|
||||
ecoenchants.fromtable.abattoir: true
|
||||
ecoenchants.fromtable.disable: true
|
||||
|
||||
ecoenchants.updateannounce:
|
||||
description: Informs admins of a new update
|
||||
@ -804,4 +805,7 @@ permissions:
|
||||
default: true
|
||||
ecoenchants.fromtable.abattoir:
|
||||
description: Allows getting abattoir from an enchanting table
|
||||
default: true
|
||||
ecoenchants.fromtable.disable:
|
||||
description: Allows getting disable from an enchanting table
|
||||
default: true
|
Loading…
Reference in New Issue
Block a user