mirror of
https://github.com/Auxilor/EcoEnchants.git
synced 2024-11-22 15:05:18 +01:00
Added Block Breather
This commit is contained in:
parent
a589726580
commit
d351c0b0c1
@ -222,6 +222,7 @@ public class EcoEnchants {
|
||||
public static final EcoEnchant LESION = new Lesion();
|
||||
public static final EcoEnchant CONCLUDE = new Conclude();
|
||||
public static final EcoEnchant GRACEFUL = new Graceful();
|
||||
public static final EcoEnchant BLOCK_BREATHER = new BlockBreather();
|
||||
|
||||
/**
|
||||
* Get all registered {@link EcoEnchant}s
|
||||
|
@ -0,0 +1,43 @@
|
||||
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.nms.Target;
|
||||
import com.willfp.ecoenchants.util.Rand;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.entity.EntityDamageEvent;
|
||||
|
||||
public class BlockBreather extends EcoEnchant {
|
||||
public BlockBreather() {
|
||||
super(
|
||||
new EcoEnchantBuilder("block_breather", EnchantmentType.NORMAL, Target.Applicable.HELMET, 4.0)
|
||||
);
|
||||
}
|
||||
|
||||
// START OF LISTENERS
|
||||
|
||||
@EventHandler
|
||||
public void onHurt(EntityDamageEvent event) {
|
||||
if (!(event.getEntity() instanceof Player))
|
||||
return;
|
||||
|
||||
if(!event.getCause().equals(EntityDamageEvent.DamageCause.SUFFOCATION))
|
||||
return;
|
||||
|
||||
Player player = (Player) event.getEntity();
|
||||
|
||||
if(!EnchantChecks.helmet(player, this)) return;
|
||||
int level = EnchantChecks.getHelmetLevel(player, this);
|
||||
|
||||
double chance = this.getConfig().getDouble(EcoEnchants.CONFIG_LOCATION + "chance-per-level");
|
||||
|
||||
if (Rand.randFloat(0, 1) > level * 0.01 * chance)
|
||||
return;
|
||||
|
||||
event.setCancelled(true);
|
||||
}
|
||||
|
||||
}
|
23
Plugin/src/main/resources/enchants/normal/blockbreather.yml
Normal file
23
Plugin/src/main/resources/enchants/normal/blockbreather.yml
Normal file
@ -0,0 +1,23 @@
|
||||
#
|
||||
# Block Breather EcoEnchant
|
||||
#
|
||||
|
||||
config-version: 4.0 # Don't edit this.
|
||||
|
||||
name: "Block Breather"
|
||||
|
||||
description: Chance to ignore suffocation damage.
|
||||
|
||||
obtaining:
|
||||
table: true
|
||||
villager: true
|
||||
loot: true
|
||||
rarity: rare
|
||||
|
||||
general-config:
|
||||
grindstoneable: true
|
||||
conflicts: []
|
||||
maximum-level: 3
|
||||
|
||||
config:
|
||||
chance-per-level: 15
|
@ -241,6 +241,7 @@ permissions:
|
||||
ecoenchants.fromtable.lesion: true
|
||||
ecoenchants.fromtable.conclude: true
|
||||
ecoenchants.fromtable.graceful: true
|
||||
ecoenchants.fromtable.blockbreather: true
|
||||
|
||||
ecoenchants.updateannounce:
|
||||
description: Informs admins of a new update
|
||||
@ -836,4 +837,7 @@ permissions:
|
||||
default: true
|
||||
ecoenchants.fromtable.graceful:
|
||||
description: Allows getting graceful from an enchanting table
|
||||
default: true
|
||||
ecoenchants.fromtable.blockbreather:
|
||||
description: Allows getting block breather from an enchanting table
|
||||
default: true
|
Loading…
Reference in New Issue
Block a user