package org.dynmap;

import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;

public class Armor {
    /**
     * http://www.minecraftwiki.net/wiki/Item_Durability#Armor_durability
     * We rely on getArmorContents() to return 4 armor pieces in the order
     * of: boots, pants, chest, helmet
     */
    private static final double armorPoints[] = {1.5, 3.0, 4.0, 1.5};

    public static final int getArmorPoints(Player player) {
        int currentDurability = 0;
        int baseDurability = 0;
        double baseArmorPoints = 0;
        ItemStack inventory[] = player.getInventory().getArmorContents();
        for(int i=0;i<inventory.length;i++) {
            final short maxDurability = inventory[i].getType().getMaxDurability();
            if(maxDurability < 0)
                continue;
            final short durability = inventory[i].getDurability();
            baseDurability += maxDurability;
            currentDurability += maxDurability - durability;
            baseArmorPoints += armorPoints[i];
        }
        return (int)(2*baseArmorPoints*currentDurability/baseDurability);
    }
}

@@ -85,16 +85,44 @@
 emStack;
+%0Aimport org.bukkit.Material;
 %0A%0Apublic
@@ -710,58 +710,201 @@
     
-final short maxDurability = inventory%5Bi%5D.getType()
+if(inventory%5Bi%5D == null)%0A                continue;%0A            Material m = inventory%5Bi%5D.getType();%0A            if(m == null)%0A                continue;%0A            final short maxDurability = m
 .get

Fix reported traps in Armor calculation when armor is incomplete - not sure how this didn't happen more - possibly bukkit behavior change?