From 4f17a66fc19c970bc3ad24898c969526f4415472 Mon Sep 17 00:00:00 2001 From: Genny Date: Thu, 20 Feb 2020 23:18:08 -0600 Subject: Make fire prot. a requirement for sun protection --- src/main/java/dev/genbyte/sunfright/Damager.java | 11 ++++++++++- src/main/java/dev/genbyte/sunfright/events/HelmetHandler.java | 1 + 2 files changed, 11 insertions(+), 1 deletion(-) (limited to 'src/main/java/dev/genbyte') diff --git a/src/main/java/dev/genbyte/sunfright/Damager.java b/src/main/java/dev/genbyte/sunfright/Damager.java index 8c223fb..42d6133 100644 --- a/src/main/java/dev/genbyte/sunfright/Damager.java +++ b/src/main/java/dev/genbyte/sunfright/Damager.java @@ -51,6 +51,11 @@ public class Damager extends BukkitRunnable { Damageable helmetDamageable = (Damageable) helmetMeta; int helmetDamage = helmetDamageable.getDamage(); + if (helmet.getEnchantmentLevel(Enchantment.PROTECTION_FIRE) < 1) { + applyDamage(); + return; + } + if (helmetDamage + damage >= helmet.getType().getMaxDurability()) { if (helmet.getEnchantmentLevel(Enchantment.VANISHING_CURSE) == 2) { int bindLevel = helmet.getEnchantmentLevel(Enchantment.BINDING_CURSE); @@ -71,8 +76,12 @@ public class Damager extends BukkitRunnable { } } } else { - player.damage(damage * 2); + applyDamage(); } } + + private void applyDamage() { + player.damage(damage * 2); + } } } diff --git a/src/main/java/dev/genbyte/sunfright/events/HelmetHandler.java b/src/main/java/dev/genbyte/sunfright/events/HelmetHandler.java index 5f57cef..c164536 100644 --- a/src/main/java/dev/genbyte/sunfright/events/HelmetHandler.java +++ b/src/main/java/dev/genbyte/sunfright/events/HelmetHandler.java @@ -17,6 +17,7 @@ public class HelmetHandler implements Listener { ItemStack stack = new ItemStack(Material.LEATHER_HELMET); stack.addUnsafeEnchantment(Enchantment.BINDING_CURSE, 1); stack.addUnsafeEnchantment(Enchantment.VANISHING_CURSE, 2); + stack.addEnchantment(Enchantment.PROTECTION_FIRE, 1); inv.setHelmet(stack); } -- cgit 1.4.1-3-g733a5