Right now in a plugin of mine (MaxHealth), I am having to manually add a players armor points up every time they are damaged with several switches checking their armor inventory slots. Is there a faster way to do this or is there eventually going to be a faster way?
It's not a matter of breaking or not breaking. It's a matter of factoring in armor for it's effect on damage.
player.getInventory().getArmorContents()[x].getDurability() getARmorContents() returns an array of item stacks, so you can use a for loop such for(ItemStack i : armorContents()){ //code here }
We need player.calculateDamageReduction(); I'd actually like to implement Armor skills into SkyrimRPG....
it shouldnt be too dificult to figure out. i dont think that the armors total durability is ever taken into consideration, only how many armor points they have total.
Yeah, it's based on the points, not the durability, thanks for the response though. I agree, or at least a quick, one method way of accessing a players total armor points.
tomjw64 CorrieKay Actually, I used info from the Minecraft wiki to come up with a small and cheap way. Code:java public double getDamageReduced(Player player) { org.bukkit.inventory.PlayerInventory inv = player.getInventory(); ItemStack boots = inv.getBoots(); ItemStack helmet = inv.getHelmet(); ItemStack chest = inv.getChestplate(); ItemStack pants = inv.getLeggings(); double red = 0.0; if(helmet.getType() == Material.LEATHER_HELMET)red = red + 0.04; else if(helmet.getType() == Material.GOLD_HELMET)red = red + 0.08; else if(helmet.getType() == Material.CHAINMAIL_HELMET)red = red + 0.08; else if(helmet.getType() == Material.IRON_HELMET)red = red + 0.08; else if(helmet.getType() == Material.DIAMOND_HELMET)red = red + 0.12; // if(boots.getType() == Material.LEATHER_BOOTS)red = red + 0.04; else if(boots.getType() == Material.GOLD_BOOTS)red = red + 0.04; else if(boots.getType() == Material.CHAINMAIL_BOOTS)red = red + 0.04; else if(boots.getType() == Material.IRON_BOOTS)red = red + 0.08; else if(boots.getType() == Material.DIAMOND_BOOTS)red = red + 0.12; // if(pants.getType() == Material.LEATHER_LEGGINGS)red = red + 0.08; else if(pants.getType() == Material.GOLD_LEGGINGS)red = red + 0.12; else if(pants.getType() == Material.CHAINMAIL_LEGGINGS)red = red + 0.16; else if(pants.getType() == Material.IRON_LEGGINGS)red = red + 0.20; else if(pants.getType() == Material.DIAMOND_LEGGINGS)red = red + 0.24; // if(chest.getType() == Material.LEATHER_CHESTPLATE)red = red + 0.12; else if(chest.getType() == Material.GOLD_CHESTPLATE)red = red + 0.20; else if(chest.getType() == Material.CHAINMAIL_CHESTPLATE)red = red + 0.20; else if(chest.getType() == Material.IRON_CHESTPLATE)red = red + 0.24; else if(chest.getType() == Material.DIAMOND_CHESTPLATE)red = red + 0.32; return red; } It returns a double. For example, if you have full armor points, it reduces 80%. So the method returns 0.8. It's pretty useful, I guess.