Added Stalwart
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
27
Plugin/src/main/resources/enchants/normal/stalwart.yml
Normal file
27
Plugin/src/main/resources/enchants/normal/stalwart.yml
Normal 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
|
||||
Reference in New Issue
Block a user