mirror of
https://github.com/BentoBoxWorld/AcidIsland.git
synced 2025-02-17 04:41:23 +01:00
Destroys armor if it is too damaged.
https://github.com/BentoBoxWorld/AcidIsland/issues/42
This commit is contained in:
parent
254a0ef459
commit
b4b4c52b33
@ -248,7 +248,10 @@ public class AcidEffect implements Listener {
|
||||
// Each level gives the same protection as a diamond helmet
|
||||
red += helmet.getEnchantments().getOrDefault(Enchantment.OXYGEN, 0) * 0.12;
|
||||
// Damage
|
||||
damage(helmet);
|
||||
if (damage(helmet)) {
|
||||
player.playSound(player.getLocation(), Sound.ENTITY_ITEM_BREAK, 1F, 1F);
|
||||
inv.setHelmet(null);
|
||||
}
|
||||
}
|
||||
if (boots != null) {
|
||||
switch (boots.getType()) {
|
||||
@ -271,7 +274,10 @@ public class AcidEffect implements Listener {
|
||||
break;
|
||||
}
|
||||
// Damage
|
||||
damage(boots);
|
||||
if (damage(boots)) {
|
||||
player.playSound(player.getLocation(), Sound.ENTITY_ITEM_BREAK, 1F, 1F);
|
||||
inv.setBoots(null);
|
||||
}
|
||||
}
|
||||
// Pants
|
||||
if (pants != null) {
|
||||
@ -295,7 +301,10 @@ public class AcidEffect implements Listener {
|
||||
break;
|
||||
}
|
||||
// Damage
|
||||
damage(pants);
|
||||
if (damage(pants)) {
|
||||
player.playSound(player.getLocation(), Sound.ENTITY_ITEM_BREAK, 1F, 1F);
|
||||
inv.setLeggings(null);
|
||||
}
|
||||
}
|
||||
// Chest plate
|
||||
if (chest != null) {
|
||||
@ -319,17 +328,23 @@ public class AcidEffect implements Listener {
|
||||
break;
|
||||
}
|
||||
// Damage
|
||||
damage(chest);
|
||||
if (damage(chest)) {
|
||||
player.playSound(player.getLocation(), Sound.ENTITY_ITEM_BREAK, 1F, 1F);
|
||||
inv.setChestplate(null);
|
||||
}
|
||||
}
|
||||
return red;
|
||||
}
|
||||
|
||||
private void damage(ItemStack item) {
|
||||
private boolean damage(ItemStack item) {
|
||||
ItemMeta im = item.getItemMeta();
|
||||
|
||||
if (im instanceof Damageable) {
|
||||
Damageable d = ((Damageable)item.getItemMeta());
|
||||
d.setDamage(d.getDamage() + 1);
|
||||
item.setItemMeta((ItemMeta) d);
|
||||
return d.getDamage() >= item.getType().getMaxDurability();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user