From cedfb1a53889ba8e5b1a4283c44ab95e2157b8e6 Mon Sep 17 00:00:00 2001 From: GJ Date: Tue, 22 Jan 2013 00:59:20 -0500 Subject: [PATCH] Fixed bug with checking if an entity is wearing armor. --- Changelog.txt | 1 + src/main/java/com/gmail/nossr50/util/Misc.java | 9 ++++----- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Changelog.txt b/Changelog.txt index ff5480495..0f831a841 100644 --- a/Changelog.txt +++ b/Changelog.txt @@ -10,6 +10,7 @@ Key: Version 1.4.00-dev + Added new cancellable McMMOPlayerDisarmEvent for Citizens compatibility - fires whenever a player is disarmed. = Fixed bug where Impact was applied incorrectly due to an inverted method call + = Fixed bug where Impact improperly determined the defender's armor = Fixed ArrayIndexOutOfBoundsException resulting from being unranked in a skill when using FlatFile ! Changed how Tree Feller is handled, it should now put less stress on the CPU diff --git a/src/main/java/com/gmail/nossr50/util/Misc.java b/src/main/java/com/gmail/nossr50/util/Misc.java index 0f97a4fa1..a52c03fbe 100644 --- a/src/main/java/com/gmail/nossr50/util/Misc.java +++ b/src/main/java/com/gmail/nossr50/util/Misc.java @@ -11,7 +11,6 @@ import org.bukkit.entity.LivingEntity; import org.bukkit.entity.Player; import org.bukkit.entity.Tameable; import org.bukkit.event.entity.EntityDamageEvent; -import org.bukkit.inventory.EntityEquipment; import org.bukkit.inventory.ItemStack; import org.bukkit.plugin.PluginManager; @@ -57,10 +56,10 @@ public class Misc { * @return true if the player has armor, false otherwise */ public static boolean hasArmor(LivingEntity entity) { - EntityEquipment equipment = entity.getEquipment(); - - if (equipment.getBoots() != null || equipment.getChestplate() != null || equipment.getHelmet() != null || equipment.getLeggings() != null) { - return true; + for (ItemStack armor : entity.getEquipment().getArmorContents()) { + if (armor.getType() != Material.AIR) { + return true; + } } return false;