From 71ab6789450528b70a2cbb51ce7fa0cae8c65565 Mon Sep 17 00:00:00 2001 From: GJ Date: Mon, 9 Sep 2013 12:00:37 -0400 Subject: [PATCH] Fix bug where mcMMO damage wasn't awarding XP. Fixes #1400 --- .../nossr50/skills/archery/ArcheryManager.java | 4 ++-- .../com/gmail/nossr50/skills/axes/AxesManager.java | 6 +++--- .../gmail/nossr50/skills/taming/TamingManager.java | 4 ++-- .../nossr50/skills/unarmed/UnarmedManager.java | 4 ++-- .../com/gmail/nossr50/util/skills/CombatUtils.java | 14 +++++++++----- 5 files changed, 18 insertions(+), 14 deletions(-) diff --git a/src/main/java/com/gmail/nossr50/skills/archery/ArcheryManager.java b/src/main/java/com/gmail/nossr50/skills/archery/ArcheryManager.java index 166509c77..315706353 100644 --- a/src/main/java/com/gmail/nossr50/skills/archery/ArcheryManager.java +++ b/src/main/java/com/gmail/nossr50/skills/archery/ArcheryManager.java @@ -90,7 +90,7 @@ public class ArcheryManager extends SkillManager { getPlayer().sendMessage(LocaleLoader.getString("Combat.TargetDazed")); } - CombatUtils.dealDamage(defender, Archery.dazeModifier, DamageCause.PROJECTILE, arrow); + CombatUtils.dealDamage(defender, Archery.dazeModifier, DamageCause.PROJECTILE, arrow, mcMMOPlayer, SkillType.ARCHERY); } /** @@ -104,6 +104,6 @@ public class ArcheryManager extends SkillManager { double damageBonusPercent = Math.min(((getSkillLevel() / Archery.skillShotIncreaseLevel) * Archery.skillShotIncreasePercentage), Archery.skillShotMaxBonusPercentage); double archeryBonus = damage * damageBonusPercent; - CombatUtils.dealDamage(target, archeryBonus, DamageCause.PROJECTILE, arrow); + CombatUtils.dealDamage(target, archeryBonus, DamageCause.PROJECTILE, arrow, mcMMOPlayer, SkillType.ARCHERY); } } diff --git a/src/main/java/com/gmail/nossr50/skills/axes/AxesManager.java b/src/main/java/com/gmail/nossr50/skills/axes/AxesManager.java index e9ec53b41..fd660171d 100644 --- a/src/main/java/com/gmail/nossr50/skills/axes/AxesManager.java +++ b/src/main/java/com/gmail/nossr50/skills/axes/AxesManager.java @@ -57,7 +57,7 @@ public class AxesManager extends SkillManager { public void axeMastery(LivingEntity target) { double axeBonus = Math.min(getSkillLevel() / (Axes.bonusDamageMaxBonusLevel / Axes.bonusDamageMaxBonus), Axes.bonusDamageMaxBonus); - CombatUtils.dealDamage(target, axeBonus, getPlayer()); + CombatUtils.dealDamage(target, axeBonus, getPlayer(), mcMMOPlayer, SkillType.AXES); } /** @@ -84,7 +84,7 @@ public class AxesManager extends SkillManager { damage = (damage * Axes.criticalHitPVEModifier) - damage; } - CombatUtils.dealDamage(target, damage, player); + CombatUtils.dealDamage(target, damage, player, mcMMOPlayer, SkillType.AXES); } /** @@ -134,7 +134,7 @@ public class AxesManager extends SkillManager { } } - CombatUtils.dealDamage(target, Axes.greaterImpactBonusDamage, player); + CombatUtils.dealDamage(target, Axes.greaterImpactBonusDamage, player, mcMMOPlayer, SkillType.AXES); } /** diff --git a/src/main/java/com/gmail/nossr50/skills/taming/TamingManager.java b/src/main/java/com/gmail/nossr50/skills/taming/TamingManager.java index 548739e84..3465cd84d 100644 --- a/src/main/java/com/gmail/nossr50/skills/taming/TamingManager.java +++ b/src/main/java/com/gmail/nossr50/skills/taming/TamingManager.java @@ -123,11 +123,11 @@ public class TamingManager extends SkillManager { getPlayer().sendMessage(LocaleLoader.getString("Combat.Gore")); damage = (damage * Taming.goreModifier) - damage; - CombatUtils.dealDamage(target, damage, wolf); + CombatUtils.dealDamage(target, damage, wolf, mcMMOPlayer, SkillType.TAMING); } public void sharpenedClaws(LivingEntity target, Wolf wolf) { - CombatUtils.dealDamage(target, Taming.sharpenedClawsBonusDamage, wolf); + CombatUtils.dealDamage(target, Taming.sharpenedClawsBonusDamage, wolf, mcMMOPlayer, SkillType.TAMING); } /** diff --git a/src/main/java/com/gmail/nossr50/skills/unarmed/UnarmedManager.java b/src/main/java/com/gmail/nossr50/skills/unarmed/UnarmedManager.java index bbfd79bc2..ca03fe670 100644 --- a/src/main/java/com/gmail/nossr50/skills/unarmed/UnarmedManager.java +++ b/src/main/java/com/gmail/nossr50/skills/unarmed/UnarmedManager.java @@ -116,7 +116,7 @@ public class UnarmedManager extends SkillManager { public void berserkDamage(LivingEntity target, double damage) { damage = (damage * Unarmed.berserkDamageModifier) - damage; - CombatUtils.dealDamage(target, damage, getPlayer()); + CombatUtils.dealDamage(target, damage, getPlayer(), mcMMOPlayer, SkillType.UNARMED); } /** @@ -127,7 +127,7 @@ public class UnarmedManager extends SkillManager { public void ironArm(LivingEntity target) { int unarmedBonus = Math.min(Unarmed.ironArmMinBonusDamage + (getSkillLevel() / Unarmed.ironArmIncreaseLevel), Unarmed.ironArmMaxBonusDamage); - CombatUtils.dealDamage(target, unarmedBonus, getPlayer()); + CombatUtils.dealDamage(target, unarmedBonus, getPlayer(), mcMMOPlayer, SkillType.UNARMED); } /** diff --git a/src/main/java/com/gmail/nossr50/util/skills/CombatUtils.java b/src/main/java/com/gmail/nossr50/util/skills/CombatUtils.java index 1b05670e9..dc9395a5a 100644 --- a/src/main/java/com/gmail/nossr50/util/skills/CombatUtils.java +++ b/src/main/java/com/gmail/nossr50/util/skills/CombatUtils.java @@ -348,7 +348,7 @@ public final class CombatUtils { * @param damage Amount of damage to attempt to do */ public static void dealDamage(LivingEntity target, double damage) { - dealDamage(target, damage, DamageCause.CUSTOM, null); + dealDamage(target, damage, DamageCause.CUSTOM, null, null, null); } /** @@ -358,8 +358,8 @@ public final class CombatUtils { * @param damage Amount of damage to attempt to do * @param attacker Player to pass to event as damager */ - public static void dealDamage(LivingEntity target, double damage, LivingEntity attacker) { - dealDamage(target, damage, DamageCause.ENTITY_ATTACK, attacker); + public static void dealDamage(LivingEntity target, double damage, LivingEntity attacker, McMMOPlayer mcMMOPlayer, SkillType skill) { + dealDamage(target, damage, DamageCause.ENTITY_ATTACK, attacker, mcMMOPlayer, skill); } /** @@ -369,7 +369,7 @@ public final class CombatUtils { * @param damage Amount of damage to attempt to do * @param attacker Player to pass to event as damager */ - public static void dealDamage(LivingEntity target, double damage, DamageCause cause, Entity attacker) { + public static void dealDamage(LivingEntity target, double damage, DamageCause cause, Entity attacker, McMMOPlayer mcMMOPlayer, SkillType skill) { if (target.isDead()) { return; } @@ -385,6 +385,10 @@ public final class CombatUtils { damage = damageEvent.getDamage(); } + if (mcMMOPlayer != null) { + startGainXp(mcMMOPlayer, target, skill); + } + target.damage(damage); } @@ -432,7 +436,7 @@ public final class CombatUtils { break; } - dealDamage(livingEntity, damageAmount, attacker); + dealDamage(livingEntity, damageAmount, attacker, UserManager.getPlayer(attacker), type); numberOfTargets--; } }