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,147 +40,143 @@ import com.gmail.nossr50.skills.Unarmed;
public class Combat 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()) if(event.isCancelled() || event.getDamage() == 0 || event.getEntity().isDead())
return; return;
if(event instanceof EntityDamageByEntityEvent) //Declare Things
Entity damager = event.getDamager();
LivingEntity target = (LivingEntity) event.getEntity();
int damage = event.getDamage();
/*
* PLAYER VERSUS ENTITIES
*/
if(damager instanceof Player)
{ {
//Declare Things Player attacker = (Player) event.getDamager();
EntityDamageByEntityEvent eEvent = (EntityDamageByEntityEvent) event; ItemStack itemInHand = attacker.getItemInHand();
Entity damager = eEvent.getDamager(); PlayerProfile PPa = Users.getProfile(attacker);
LivingEntity target = (LivingEntity) eEvent.getEntity();
int damage = eEvent.getDamage();
/* //If there are any abilities to activate
* PLAYER VERSUS ENTITIES combatAbilityChecks(attacker, PPa, pluginx);
*/
if(damager instanceof Player) //Damage modifiers and proc checks
if(m.isSwords(itemInHand) && mcPermissions.getInstance().swords(attacker))
{ {
Player attacker = (Player) eEvent.getDamager(); if(!pluginx.misc.bleedTracker.contains(target)) //Bleed
ItemStack itemInHand = attacker.getItemInHand(); Swords.bleedCheck(attacker, target, pluginx);
PlayerProfile PPa = Users.getProfile(attacker);
//If there are any abilities to activate if (!(event instanceof FakeEntityDamageByEntityEvent) && PPa.getSerratedStrikesMode())
combatAbilityChecks(attacker, PPa, pluginx); Swords.applySerratedStrikes(attacker, event, pluginx);
//Damage modifiers and proc checks if(target instanceof Player)
if(m.isSwords(itemInHand) && mcPermissions.getInstance().swords(attacker)) PvPExperienceGain(attacker, PPa, (Player) target, damage, SkillType.SWORDS);
{ else if(!pluginx.misc.mobSpawnerList.contains(target.getEntityId()))
if(!pluginx.misc.bleedTracker.contains(target)) //Bleed PvEExperienceGain(attacker, PPa, target, damage, SkillType.SWORDS);
Swords.bleedCheck(attacker, target, pluginx); }
else if(m.isAxes(itemInHand) && mcPermissions.getInstance().axes(attacker))
{
if(Users.getProfile(attacker).getSkillLevel(SkillType.AXES) >= 500)
event.setDamage(damage + 4);
if (!(event instanceof FakeEntityDamageByEntityEvent) && PPa.getSerratedStrikesMode()) Axes.axeCriticalCheck(attacker, event, pluginx); //Critical hit
Swords.applySerratedStrikes(attacker, eEvent, pluginx);
if(target instanceof Player) if (!(event instanceof FakeEntityDamageByEntityEvent) && PPa.getSkullSplitterMode())
PvPExperienceGain(attacker, PPa, (Player) target, damage, SkillType.SWORDS); Axes.applyAoeDamage(attacker, event, pluginx);
else if(!pluginx.misc.mobSpawnerList.contains(target.getEntityId()))
PvEExperienceGain(attacker, PPa, target, damage, SkillType.SWORDS);
}
else if(m.isAxes(itemInHand) && mcPermissions.getInstance().axes(attacker))
{
if(Users.getProfile(attacker).getSkillLevel(SkillType.AXES) >= 500)
event.setDamage(damage + 4);
Axes.axeCriticalCheck(attacker, eEvent, pluginx); //Critical hit if(target instanceof Player)
PvPExperienceGain(attacker, PPa, (Player) target, event.getDamage(), SkillType.AXES);
else if(!pluginx.misc.mobSpawnerList.contains(target.getEntityId()))
PvEExperienceGain(attacker, PPa, target, event.getDamage(), SkillType.AXES);
}
else if(itemInHand.getTypeId() == 0 && mcPermissions.getInstance().unarmed(attacker)) //Unarmed
{
Unarmed.unarmedBonus(attacker, event);
if(PPa.getBerserkMode())
event.setDamage(event.getDamage() + (event.getDamage() / 2));
if(target instanceof Player)
Unarmed.disarmProcCheck(attacker, (Player) target); //Disarm
if (!(event instanceof FakeEntityDamageByEntityEvent) && PPa.getSkullSplitterMode()) if(target instanceof Player)
Axes.applyAoeDamage(attacker, eEvent, pluginx); PvPExperienceGain(attacker, PPa, (Player) target, event.getDamage(), SkillType.UNARMED);
else if(!pluginx.misc.mobSpawnerList.contains(target.getEntityId()))
if(target instanceof Player) PvEExperienceGain(attacker, PPa, target, event.getDamage(), SkillType.UNARMED);
PvPExperienceGain(attacker, PPa, (Player) target, eEvent.getDamage(), SkillType.AXES);
else if(!pluginx.misc.mobSpawnerList.contains(target.getEntityId()))
PvEExperienceGain(attacker, PPa, target, eEvent.getDamage(), SkillType.AXES);
}
else if(itemInHand.getTypeId() == 0 && mcPermissions.getInstance().unarmed(attacker)) //Unarmed
{
Unarmed.unarmedBonus(attacker, eEvent);
if(PPa.getBerserkMode())
event.setDamage(eEvent.getDamage() + (eEvent.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);
else if(!pluginx.misc.mobSpawnerList.contains(target.getEntityId()))
PvEExperienceGain(attacker, PPa, target, eEvent.getDamage(), SkillType.UNARMED);
}
//Player use bone on wolf.
else if(target instanceof Wolf)
{
Wolf wolf = (Wolf) target;
if(itemInHand.getTypeId() == 352 && mcPermissions.getInstance().taming(attacker))
{
event.setCancelled(true);
if(wolf.isTamed())
attacker.sendMessage(mcLocale.getString("Combat.BeastLore")+" "+
mcLocale.getString("Combat.BeastLoreOwner", new Object[] {Taming.getOwnerName(wolf)})+" "+
mcLocale.getString("Combat.BeastLoreHealthWolfTamed", new Object[] {wolf.getHealth()}));
else
attacker.sendMessage(mcLocale.getString("Combat.BeastLore")+" "+
mcLocale.getString("Combat.BeastLoreHealthWolf", new Object[] {wolf.getHealth()}));
}
}
} }
/* //Player use bone on wolf.
* TAMING (WOLVES VERSUS ENTITIES)
*/
else if(damager instanceof Wolf)
{
Wolf wolf = (Wolf) damager;
if (wolf.isTamed() && Taming.ownerOnline(wolf, pluginx))
{
Player master = Taming.getOwner(wolf, pluginx);
if (master == null) //Can it really happen?
return;
PlayerProfile PPo = Users.getProfile(master);
if(mcPermissions.getInstance().taming(master))
{
//Fast Food Service
Taming.fastFoodService(PPo, wolf, event);
//Sharpened Claws
Taming.sharpenedClaws(PPo, event);
//Gore
Taming.gore(PPo, event, master, pluginx);
//Reward XP
Taming.rewardXp(event, pluginx, master);
}
}
}
//Another offensive check for Archery
else if(damager instanceof Arrow)
archeryCheck((EntityDamageByEntityEvent)event, pluginx);
/*
* DEFENSIVE CHECKS
*/
if(target instanceof Player)
{
Swords.counterAttackChecks(eEvent);
Acrobatics.dodgeChecks(eEvent);
}
/*
* DEFENSIVE CHECKS FOR WOLVES
*/
else if(target instanceof Wolf) else if(target instanceof Wolf)
{ {
Wolf wolf = (Wolf) target; Wolf wolf = (Wolf) target;
if(wolf.isTamed() && Taming.ownerOnline(wolf, pluginx))
Taming.preventDamage(eEvent, pluginx); if(itemInHand.getTypeId() == 352 && mcPermissions.getInstance().taming(attacker))
{
event.setCancelled(true);
if(wolf.isTamed())
attacker.sendMessage(mcLocale.getString("Combat.BeastLore")+" "+
mcLocale.getString("Combat.BeastLoreOwner", new Object[] {Taming.getOwnerName(wolf)})+" "+
mcLocale.getString("Combat.BeastLoreHealthWolfTamed", new Object[] {wolf.getHealth()}));
else
attacker.sendMessage(mcLocale.getString("Combat.BeastLore")+" "+
mcLocale.getString("Combat.BeastLoreHealthWolf", new Object[] {wolf.getHealth()}));
}
} }
} }
/*
* TAMING (WOLVES VERSUS ENTITIES)
*/
else if(damager instanceof Wolf)
{
Wolf wolf = (Wolf) damager;
if (wolf.isTamed() && Taming.ownerOnline(wolf, pluginx))
{
Player master = Taming.getOwner(wolf, pluginx);
if (master == null) //Can it really happen?
return;
PlayerProfile PPo = Users.getProfile(master);
if(mcPermissions.getInstance().taming(master))
{
//Fast Food Service
Taming.fastFoodService(PPo, wolf, event);
//Sharpened Claws
Taming.sharpenedClaws(PPo, event);
//Gore
Taming.gore(PPo, event, master, pluginx);
//Reward XP
Taming.rewardXp(event, pluginx, master);
}
}
}
//Another offensive check for Archery
else if(damager instanceof Arrow)
archeryCheck((EntityDamageByEntityEvent)event, pluginx);
/*
* DEFENSIVE CHECKS
*/
if(target instanceof Player)
{
Swords.counterAttackChecks(event);
Acrobatics.dodgeChecks(event);
}
/*
* DEFENSIVE CHECKS FOR WOLVES
*/
else if(target instanceof Wolf)
{
Wolf wolf = (Wolf) target;
if(wolf.isTamed() && Taming.ownerOnline(wolf, pluginx))
Taming.preventDamage(event, pluginx);
}
} }
public static void combatAbilityChecks(Player attacker, PlayerProfile PPa, Plugin pluginx) public static void combatAbilityChecks(Player attacker, PlayerProfile PPa, Plugin pluginx)

View File

@ -125,7 +125,7 @@ public class mcEntityListener implements Listener
if(Party.getInstance().inSameParty(defender, attacker)) if(Party.getInstance().inSameParty(defender, attacker))
event.setCancelled(true); 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 * Check to see if the defender took damage so we can apply recently hurt