mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2024-11-26 23:26:45 +01:00
Removed redundancy
This commit is contained in:
parent
bf38fc9819
commit
4b26732f51
@ -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();
|
||||||
//Declare Things
|
LivingEntity target = (LivingEntity) event.getEntity();
|
||||||
EntityDamageByEntityEvent eEvent = (EntityDamageByEntityEvent) event;
|
int damage = event.getDamage();
|
||||||
Entity damager = eEvent.getDamager();
|
|
||||||
LivingEntity target = (LivingEntity) eEvent.getEntity();
|
/*
|
||||||
int damage = eEvent.getDamage();
|
* PLAYER VERSUS ENTITIES
|
||||||
|
*/
|
||||||
|
if(damager instanceof Player)
|
||||||
|
{
|
||||||
|
Player attacker = (Player) event.getDamager();
|
||||||
|
ItemStack itemInHand = attacker.getItemInHand();
|
||||||
|
PlayerProfile PPa = Users.getProfile(attacker);
|
||||||
|
|
||||||
/*
|
//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 (!(event instanceof FakeEntityDamageByEntityEvent) && PPa.getSerratedStrikesMode())
|
||||||
|
Swords.applySerratedStrikes(attacker, event, pluginx);
|
||||||
|
|
||||||
|
if(target instanceof Player)
|
||||||
|
PvPExperienceGain(attacker, PPa, (Player) target, damage, SkillType.SWORDS);
|
||||||
|
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);
|
||||||
|
|
||||||
//If there are any abilities to activate
|
Axes.axeCriticalCheck(attacker, event, pluginx); //Critical hit
|
||||||
combatAbilityChecks(attacker, PPa, pluginx);
|
|
||||||
|
|
||||||
//Damage modifiers and proc checks
|
if (!(event instanceof FakeEntityDamageByEntityEvent) && PPa.getSkullSplitterMode())
|
||||||
if(m.isSwords(itemInHand) && mcPermissions.getInstance().swords(attacker))
|
Axes.applyAoeDamage(attacker, event, pluginx);
|
||||||
{
|
|
||||||
if(!pluginx.misc.bleedTracker.contains(target)) //Bleed
|
|
||||||
Swords.bleedCheck(attacker, target, pluginx);
|
|
||||||
|
|
||||||
if (!(event instanceof FakeEntityDamageByEntityEvent) && PPa.getSerratedStrikesMode())
|
|
||||||
Swords.applySerratedStrikes(attacker, eEvent, pluginx);
|
|
||||||
|
|
||||||
if(target instanceof Player)
|
|
||||||
PvPExperienceGain(attacker, PPa, (Player) target, damage, SkillType.SWORDS);
|
|
||||||
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 (!(event instanceof FakeEntityDamageByEntityEvent) && PPa.getSkullSplitterMode())
|
|
||||||
Axes.applyAoeDamage(attacker, eEvent, pluginx);
|
|
||||||
|
|
||||||
if(target instanceof Player)
|
|
||||||
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.
|
if(target instanceof Player)
|
||||||
else if(target instanceof Wolf)
|
PvPExperienceGain(attacker, PPa, (Player) target, event.getDamage(), SkillType.AXES);
|
||||||
{
|
else if(!pluginx.misc.mobSpawnerList.contains(target.getEntityId()))
|
||||||
Wolf wolf = (Wolf) target;
|
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(itemInHand.getTypeId() == 352 && mcPermissions.getInstance().taming(attacker))
|
if(target instanceof Player)
|
||||||
{
|
PvPExperienceGain(attacker, PPa, (Player) target, event.getDamage(), SkillType.UNARMED);
|
||||||
event.setCancelled(true);
|
else if(!pluginx.misc.mobSpawnerList.contains(target.getEntityId()))
|
||||||
if(wolf.isTamed())
|
PvEExperienceGain(attacker, PPa, target, event.getDamage(), SkillType.UNARMED);
|
||||||
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)
|
||||||
|
@ -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
|
||||||
|
Loading…
Reference in New Issue
Block a user