From 92cc494087ac33fdf0d33010d1173ed15cb0e49d Mon Sep 17 00:00:00 2001 From: GJ Date: Sat, 17 Mar 2012 12:52:48 -0400 Subject: [PATCH] *CLEANUP* - Unarmed.java --- src/main/java/com/gmail/nossr50/Combat.java | 4 +- .../com/gmail/nossr50/skills/Unarmed.java | 89 ++++++++++--------- 2 files changed, 48 insertions(+), 45 deletions(-) diff --git a/src/main/java/com/gmail/nossr50/Combat.java b/src/main/java/com/gmail/nossr50/Combat.java index 33934ddb5..2c17c8c3f 100644 --- a/src/main/java/com/gmail/nossr50/Combat.java +++ b/src/main/java/com/gmail/nossr50/Combat.java @@ -81,14 +81,14 @@ public class Combat { startGainXp(attacker, PPa, target, SkillType.AXES, plugin); } else if (itemInHand.getType().equals(Material.AIR) && mcPermissions.getInstance().unarmed(attacker)) { - Unarmed.unarmedBonus(attacker, event); + Unarmed.unarmedBonus(PPa, event); if (PPa.getBerserkMode()) { event.setDamage(damage + (damage / 2)); } if (targetType.equals(EntityType.PLAYER)) { - Unarmed.disarmProcCheck(attacker, (Player) target); + Unarmed.disarmProcCheck(PPa, (Player) target); } startGainXp(attacker, PPa, target, SkillType.UNARMED, plugin); diff --git a/src/main/java/com/gmail/nossr50/skills/Unarmed.java b/src/main/java/com/gmail/nossr50/skills/Unarmed.java index a1bdbf02f..d4adbeb3b 100644 --- a/src/main/java/com/gmail/nossr50/skills/Unarmed.java +++ b/src/main/java/com/gmail/nossr50/skills/Unarmed.java @@ -4,51 +4,54 @@ import org.bukkit.Material; import org.bukkit.entity.Player; import org.bukkit.event.entity.EntityDamageByEntityEvent; import org.bukkit.inventory.ItemStack; -import com.gmail.nossr50.Users; + import com.gmail.nossr50.m; +import com.gmail.nossr50.datatypes.PlayerProfile; import com.gmail.nossr50.datatypes.SkillType; import com.gmail.nossr50.locale.mcLocale; public class Unarmed { - - public static void unarmedBonus(Player attacker, EntityDamageByEntityEvent event) - { - int bonus = 3; - - //Add 1 DMG for every 50 skill levels - bonus += Users.getProfile(attacker).getSkillLevel(SkillType.UNARMED)/50; - - if(bonus > 8) - bonus = 8; - - event.setDamage(event.getDamage() + bonus); - } - - public static void disarmProcCheck(Player attacker, Player defender) - { - int skillLevel = Users.getProfile(attacker).getSkillLevel(SkillType.UNARMED); - if(defender.getItemInHand() != null && defender.getItemInHand().getType() != Material.AIR) - { - if(skillLevel >= 1000) - { - if(Math.random() * 3000 <= 1000) - { - ItemStack item = defender.getItemInHand(); - defender.sendMessage(mcLocale.getString("Skills.Disarmed")); - m.mcDropItem(defender.getLocation(), item); - defender.setItemInHand(null); - } - } - else - { - if(Math.random() * 3000 <= skillLevel) - { - ItemStack item = defender.getItemInHand(); - defender.sendMessage(mcLocale.getString("Skills.Disarmed")); - m.mcDropItem(defender.getLocation(), item); - defender.setItemInHand(null); - } - } - } - } -} \ No newline at end of file + + /** + * Apply bonus to Unarmed damage. + * + * @param PPa Profile of the attacking player + * @param event The event to modify + */ + public static void unarmedBonus(PlayerProfile PPa, EntityDamageByEntityEvent event) { + final int MAX_BONUS = 8; + int bonus = 3; + + bonus += PPa.getSkillLevel(SkillType.UNARMED) / 50; //Add 1 DMG for every 50 skill levels + + if (bonus > MAX_BONUS) { + bonus = MAX_BONUS; + } + + event.setDamage(event.getDamage() + bonus); + } + + /** + * Check for disarm. + * + * @param PPa Profile of the attacking player + * @param defender The defending player + */ + public static void disarmProcCheck(PlayerProfile PPa, Player defender) { + final int MAX_BONUS_LEVEL = 1000; + + int skillLevel = PPa.getSkillLevel(SkillType.UNARMED); + int skillCheck = m.skillCheck(skillLevel, MAX_BONUS_LEVEL); + + if (defender.getItemInHand().getType().equals(Material.AIR)) { + if (Math.random() * 3000 <= skillCheck) { + ItemStack item = defender.getItemInHand(); + + defender.sendMessage(mcLocale.getString("Skills.Disarmed")); + + m.mcDropItem(defender.getLocation(), item); + defender.setItemInHand(new ItemStack(Material.AIR)); + } + } + } +}