Added Stalwart

This commit is contained in:
Auxilor
2020-11-06 20:25:00 +00:00
parent f0c4e16635
commit bfd39c066b
3 changed files with 64 additions and 0 deletions

View File

@@ -244,6 +244,8 @@ public class EcoEnchants {
public static final EcoEnchant TEAR_ARTIFACT = new TearArtifact();
public static final EcoEnchant BACKSTAB = new Backstab();
public static final EcoEnchant EXTRACTION = new Extraction();
public static final EcoEnchant DWELLER = new Dweller();
public static final EcoEnchant STALWART = new Stalwart();
/**
* Get all registered {@link EcoEnchant}s

View File

@@ -0,0 +1,35 @@
package com.willfp.ecoenchants.enchantments.ecoenchants.normal;
import com.willfp.ecoenchants.enchantments.EcoEnchant;
import com.willfp.ecoenchants.enchantments.EcoEnchants;
import com.willfp.ecoenchants.enchantments.util.EnchantmentUtils;
import org.bukkit.entity.LivingEntity;
import org.bukkit.event.entity.EntityDamageEvent;
import org.bukkit.potion.PotionEffect;
import org.bukkit.potion.PotionEffectType;
public final class Stalwart extends EcoEnchant {
public Stalwart() {
super(
"stalwart", EnchantmentType.NORMAL
);
}
// START OF LISTENERS
@Override
public void onDamageWearingArmor(LivingEntity victim, int level, EntityDamageEvent event) {
if(!EnchantmentUtils.passedChance(this, level))
return;
int duration = this.getConfig().getInt(EcoEnchants.CONFIG_LOCATION + "duration-per-level");
duration *= level;
int amplifier = (int) Math.ceil((double) level / 4) - 1;
victim.addPotionEffect(new PotionEffect(PotionEffectType.DAMAGE_RESISTANCE, duration, amplifier, false, false, true));
event.setCancelled(true);
}
}

View File

@@ -0,0 +1,27 @@
#
# Stalwart EcoEnchant
#
name: "Stalwart"
description: Chance to get resistance for a short time when taking damage.
enabled: true
obtaining:
table: true
villager: true
loot: true
rarity: epic
general-config:
targets:
- helmet
- chestplate
- leggings
- boots
grindstoneable: true
conflicts: []
maximum-level: 3
config:
chance-per-level: 2
duration-per-level: 5 # Ticks to get resistance for