Added Respirator

This commit is contained in:
Auxilor 2020-09-12 15:14:12 +01:00
parent 3ae6867146
commit 7e1cc48766
4 changed files with 67 additions and 0 deletions

View File

@ -226,6 +226,7 @@ public class EcoEnchants {
public static final EcoEnchant VOLTAGE = new Voltage();
public static final EcoEnchant TRANSFUSE = new Transfuse();
public static final EcoEnchant INACCURACY_CURSE = new InaccuracyCurse();
public static final EcoEnchant RESPIRATOR = new Respirator();
/**
* Get all registered {@link EcoEnchant}s

View File

@ -0,0 +1,37 @@
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 org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.entity.EntityDamageEvent;
public class Respirator extends EcoEnchant {
public Respirator() {
super(
new EcoEnchantBuilder("respirator", EnchantmentType.NORMAL, 5.0)
);
}
// START OF LISTENERS
@EventHandler
public void onHurt(EntityDamageEvent event) {
if(!event.getCause().equals(EntityDamageEvent.DamageCause.DRAGON_BREATH)) return;
if(!(event.getEntity() instanceof LivingEntity)) return;
if(!EnchantChecks.helmet((LivingEntity) event.getEntity(), this)) return;
int level = EnchantChecks.getHelmetLevel((LivingEntity) event.getEntity(), this);
double reduction = this.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "percent-less-per-level");
double multiplier = 1 - (reduction/100 * level);
event.setDamage(event.getDamage() * multiplier);
}
}

View File

@ -0,0 +1,25 @@
#
# Respirator EcoEnchant
#
config-version: 5.0 # Don't edit this.
name: "Respirator"
description: Reduces dragon breath damage.
enabled: true
obtaining:
table: true
villager: true
loot: true
rarity: special
general-config:
targets:
- helmet
grindstoneable: true
conflicts: []
maximum-level: 6
config:
percent-less-per-level: 15 # Points * Percent less / 100 * damage = damage taken

View File

@ -245,6 +245,7 @@ permissions:
ecoenchants.fromtable.voltage: true
ecoenchants.fromtable.transfuse: true
ecoenchants.fromtable.inaccuracycurse: true
ecoenchants.fromtable.respirator: true
ecoenchants.updateannounce:
description: Informs admins of a new update
@ -852,4 +853,7 @@ permissions:
default: true
ecoenchants.fromtable.inaccuracycurse:
description: Allows getting curse of inaccuracy from an enchanting table
default: true
ecoenchants.fromtable.respirator:
description: Allows getting respirator from an enchanting table
default: true