From 5da59e6f0a88130ba328b543d7a725cf24b6bcc5 Mon Sep 17 00:00:00 2001 From: nossr50 Date: Sun, 4 Mar 2012 12:21:24 -0800 Subject: [PATCH] Reworked abilityDurabilityLoss() to take an int as dmg dealt --- src/main/java/com/gmail/nossr50/skills/Excavation.java | 2 +- src/main/java/com/gmail/nossr50/skills/Mining.java | 9 +++++++-- src/main/java/com/gmail/nossr50/skills/Skills.java | 6 ++---- src/main/java/com/gmail/nossr50/skills/WoodCutting.java | 3 +-- 4 files changed, 11 insertions(+), 9 deletions(-) diff --git a/src/main/java/com/gmail/nossr50/skills/Excavation.java b/src/main/java/com/gmail/nossr50/skills/Excavation.java index 7fbbfc0f0..63904deb1 100644 --- a/src/main/java/com/gmail/nossr50/skills/Excavation.java +++ b/src/main/java/com/gmail/nossr50/skills/Excavation.java @@ -173,7 +173,7 @@ public class Excavation public static void gigaDrillBreaker(Player player, Block block) { - Skills.abilityDurabilityLoss(player.getItemInHand()); + Skills.abilityDurabilityLoss(player.getItemInHand(), LoadProperties.abilityDurabilityLoss); if(block.getData() != (byte)5) { PlayerAnimationEvent armswing = new PlayerAnimationEvent(player); diff --git a/src/main/java/com/gmail/nossr50/skills/Mining.java b/src/main/java/com/gmail/nossr50/skills/Mining.java index fd52f42e9..2aa0f9614 100644 --- a/src/main/java/com/gmail/nossr50/skills/Mining.java +++ b/src/main/java/com/gmail/nossr50/skills/Mining.java @@ -177,10 +177,15 @@ public class Mining public static void SuperBreakerBlockCheck(Player player, Block block, mcMMO plugin) { PlayerProfile PP = Users.getProfile(player); - Skills.abilityDurabilityLoss(player.getItemInHand()); + Material type = block.getType(); + + //Obsidian needs to do more damage than normal + if(type != Material.OBSIDIAN) + Skills.abilityDurabilityLoss(player.getItemInHand(), LoadProperties.abilityDurabilityLoss); + else + Skills.abilityDurabilityLoss(player.getItemInHand(), LoadProperties.abilityDurabilityLoss*5); //Pre-processing - Material type = block.getType(); int xp = 0; PlayerAnimationEvent armswing = new PlayerAnimationEvent(player); diff --git a/src/main/java/com/gmail/nossr50/skills/Skills.java b/src/main/java/com/gmail/nossr50/skills/Skills.java index 6c4498580..a6022ba4f 100644 --- a/src/main/java/com/gmail/nossr50/skills/Skills.java +++ b/src/main/java/com/gmail/nossr50/skills/Skills.java @@ -271,15 +271,13 @@ public class Skills return false; } - public static void abilityDurabilityLoss(ItemStack inhand) + public static void abilityDurabilityLoss(ItemStack inhand, int durabilityLoss) { if(LoadProperties.toolsLoseDurabilityFromAbilities) { if(!inhand.containsEnchantment(Enchantment.DURABILITY)) { - short durability = inhand.getDurability(); - durability += (LoadProperties.abilityDurabilityLoss); - inhand.setDurability(durability); + inhand.setDurability((short)(inhand.getDurability()+durabilityLoss)); } } } diff --git a/src/main/java/com/gmail/nossr50/skills/WoodCutting.java b/src/main/java/com/gmail/nossr50/skills/WoodCutting.java index 85acd0d98..1aee67d65 100644 --- a/src/main/java/com/gmail/nossr50/skills/WoodCutting.java +++ b/src/main/java/com/gmail/nossr50/skills/WoodCutting.java @@ -160,7 +160,6 @@ public class WoodCutting PP.addXP(SkillType.WOODCUTTING, xp, player); //Tree Feller gives nerf'd XP Skills.XpCheckSkill(SkillType.WOODCUTTING, player); - Skills.abilityDurabilityLoss(player.getItemInHand()); } private static boolean treeFellerCompatible(Block block) @@ -265,7 +264,7 @@ public class WoodCutting PlayerAnimationEvent armswing = new PlayerAnimationEvent(player); Bukkit.getPluginManager().callEvent(armswing); - Skills.abilityDurabilityLoss(player.getItemInHand()); + Skills.abilityDurabilityLoss(player.getItemInHand(), LoadProperties.abilityDurabilityLoss); if(LoadProperties.spoutEnabled) SpoutStuff.playSoundForPlayer(SoundEffect.POP, player, block.getLocation()); }