Removed redundancy

This commit is contained in:
nossr50 2012-02-26 04:15:50 -08:00
parent bf38fc9819
commit 4b26732f51
2 changed files with 121 additions and 125 deletions

View File

@ -40,25 +40,22 @@ import com.gmail.nossr50.skills.Unarmed;
public class Combat
{
public static void combatChecks(EntityDamageEvent event, mcMMO pluginx)
public static void combatChecks(EntityDamageByEntityEvent event, mcMMO pluginx)
{
if(event.isCancelled() || event.getDamage() == 0 || event.getEntity().isDead())
return;
if(event instanceof EntityDamageByEntityEvent)
{
//Declare Things
EntityDamageByEntityEvent eEvent = (EntityDamageByEntityEvent) event;
Entity damager = eEvent.getDamager();
LivingEntity target = (LivingEntity) eEvent.getEntity();
int damage = eEvent.getDamage();
Entity damager = event.getDamager();
LivingEntity target = (LivingEntity) event.getEntity();
int damage = event.getDamage();
/*
* PLAYER VERSUS ENTITIES
*/
if(damager instanceof Player)
{
Player attacker = (Player) eEvent.getDamager();
Player attacker = (Player) event.getDamager();
ItemStack itemInHand = attacker.getItemInHand();
PlayerProfile PPa = Users.getProfile(attacker);
@ -72,7 +69,7 @@ public class Combat
Swords.bleedCheck(attacker, target, pluginx);
if (!(event instanceof FakeEntityDamageByEntityEvent) && PPa.getSerratedStrikesMode())
Swords.applySerratedStrikes(attacker, eEvent, pluginx);
Swords.applySerratedStrikes(attacker, event, pluginx);
if(target instanceof Player)
PvPExperienceGain(attacker, PPa, (Player) target, damage, SkillType.SWORDS);
@ -84,28 +81,28 @@ public class Combat
if(Users.getProfile(attacker).getSkillLevel(SkillType.AXES) >= 500)
event.setDamage(damage + 4);
Axes.axeCriticalCheck(attacker, eEvent, pluginx); //Critical hit
Axes.axeCriticalCheck(attacker, event, pluginx); //Critical hit
if (!(event instanceof FakeEntityDamageByEntityEvent) && PPa.getSkullSplitterMode())
Axes.applyAoeDamage(attacker, eEvent, pluginx);
Axes.applyAoeDamage(attacker, event, pluginx);
if(target instanceof Player)
PvPExperienceGain(attacker, PPa, (Player) target, eEvent.getDamage(), SkillType.AXES);
PvPExperienceGain(attacker, PPa, (Player) target, event.getDamage(), SkillType.AXES);
else if(!pluginx.misc.mobSpawnerList.contains(target.getEntityId()))
PvEExperienceGain(attacker, PPa, target, eEvent.getDamage(), SkillType.AXES);
PvEExperienceGain(attacker, PPa, target, event.getDamage(), SkillType.AXES);
}
else if(itemInHand.getTypeId() == 0 && mcPermissions.getInstance().unarmed(attacker)) //Unarmed
{
Unarmed.unarmedBonus(attacker, eEvent);
Unarmed.unarmedBonus(attacker, event);
if(PPa.getBerserkMode())
event.setDamage(eEvent.getDamage() + (eEvent.getDamage() / 2));
event.setDamage(event.getDamage() + (event.getDamage() / 2));
if(target instanceof Player)
Unarmed.disarmProcCheck(attacker, (Player) target); //Disarm
if(target instanceof Player)
PvPExperienceGain(attacker, PPa, (Player) target, eEvent.getDamage(), SkillType.UNARMED);
PvPExperienceGain(attacker, PPa, (Player) target, event.getDamage(), SkillType.UNARMED);
else if(!pluginx.misc.mobSpawnerList.contains(target.getEntityId()))
PvEExperienceGain(attacker, PPa, target, eEvent.getDamage(), SkillType.UNARMED);
PvEExperienceGain(attacker, PPa, target, event.getDamage(), SkillType.UNARMED);
}
//Player use bone on wolf.
@ -167,8 +164,8 @@ public class Combat
*/
if(target instanceof Player)
{
Swords.counterAttackChecks(eEvent);
Acrobatics.dodgeChecks(eEvent);
Swords.counterAttackChecks(event);
Acrobatics.dodgeChecks(event);
}
/*
@ -178,8 +175,7 @@ public class Combat
{
Wolf wolf = (Wolf) target;
if(wolf.isTamed() && Taming.ownerOnline(wolf, pluginx))
Taming.preventDamage(eEvent, pluginx);
}
Taming.preventDamage(event, pluginx);
}
}

View File

@ -125,7 +125,7 @@ public class mcEntityListener implements Listener
if(Party.getInstance().inSameParty(defender, attacker))
event.setCancelled(true);
}
Combat.combatChecks(event, plugin);
Combat.combatChecks(eventb, plugin);
}
/*
* Check to see if the defender took damage so we can apply recently hurt