mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2024-11-23 05:36:46 +01:00
Hopefully a better fix for the previously mentioned issue.
This commit is contained in:
parent
06cf0ff2c2
commit
3d275a4f53
@ -52,19 +52,18 @@ public class Combat {
|
|||||||
*
|
*
|
||||||
* @param event The event to run the combat checks on.
|
* @param event The event to run the combat checks on.
|
||||||
*/
|
*/
|
||||||
public static void combatChecks(EntityDamageByEntityEvent event, Entity damager, LivingEntity target) {
|
public static void combatChecks(EntityDamageByEntityEvent event, Entity attacker, LivingEntity target) {
|
||||||
boolean targetIsPlayer = (target.getType() == EntityType.PLAYER);
|
boolean targetIsPlayer = (target.getType() == EntityType.PLAYER);
|
||||||
boolean targetIsTamedPet = (target instanceof Tameable) ? ((Tameable) target).isTamed() : false;
|
boolean targetIsTamedPet = (target instanceof Tameable) ? ((Tameable) target).isTamed() : false;
|
||||||
|
|
||||||
switch (event.getDamager().getType()) {
|
if (attacker instanceof Player) {
|
||||||
case PLAYER:
|
Player player = (Player) attacker;
|
||||||
Player attacker = (Player) event.getDamager();
|
|
||||||
|
|
||||||
if (Misc.isNPCPlayer(attacker)) {
|
if (Misc.isNPCPlayer(player)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
ItemStack heldItem = attacker.getItemInHand();
|
ItemStack heldItem = player.getItemInHand();
|
||||||
Material heldItemType = heldItem.getType();
|
Material heldItemType = heldItem.getType();
|
||||||
|
|
||||||
if (ItemChecks.isSword(heldItem)) {
|
if (ItemChecks.isSword(heldItem)) {
|
||||||
@ -77,13 +76,13 @@ public class Combat {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Skills.abilityCheck(attacker, SkillType.SWORDS);
|
Skills.abilityCheck(player, SkillType.SWORDS);
|
||||||
|
|
||||||
SwordsManager swordsManager = new SwordsManager(attacker);
|
SwordsManager swordsManager = new SwordsManager(player);
|
||||||
swordsManager.bleedCheck(target);
|
swordsManager.bleedCheck(target);
|
||||||
swordsManager.serratedStrikes(target, event.getDamage());
|
swordsManager.serratedStrikes(target, event.getDamage());
|
||||||
|
|
||||||
startGainXp(attacker, swordsManager.getProfile(), target, SkillType.SWORDS);
|
startGainXp(player, swordsManager.getProfile(), target, SkillType.SWORDS);
|
||||||
}
|
}
|
||||||
else if (ItemChecks.isAxe(heldItem)) {
|
else if (ItemChecks.isAxe(heldItem)) {
|
||||||
if (targetIsPlayer || targetIsTamedPet) {
|
if (targetIsPlayer || targetIsTamedPet) {
|
||||||
@ -95,15 +94,15 @@ public class Combat {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Skills.abilityCheck(attacker, SkillType.AXES);
|
Skills.abilityCheck(player, SkillType.AXES);
|
||||||
|
|
||||||
AxeManager axeManager = new AxeManager(attacker);
|
AxeManager axeManager = new AxeManager(player);
|
||||||
axeManager.bonusDamage(event);
|
axeManager.bonusDamage(event);
|
||||||
axeManager.criticalHitCheck(event, target);
|
axeManager.criticalHitCheck(event, target);
|
||||||
axeManager.impact(event, target);
|
axeManager.impact(event, target);
|
||||||
axeManager.skullSplitter(target, event.getDamage());
|
axeManager.skullSplitter(target, event.getDamage());
|
||||||
|
|
||||||
startGainXp(attacker, axeManager.getProfile(), target, SkillType.AXES);
|
startGainXp(player, axeManager.getProfile(), target, SkillType.AXES);
|
||||||
}
|
}
|
||||||
else if (heldItemType == Material.AIR) {
|
else if (heldItemType == Material.AIR) {
|
||||||
if (targetIsPlayer || targetIsTamedPet) {
|
if (targetIsPlayer || targetIsTamedPet) {
|
||||||
@ -115,25 +114,27 @@ public class Combat {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Skills.abilityCheck(attacker, SkillType.UNARMED);
|
Skills.abilityCheck(player, SkillType.UNARMED);
|
||||||
|
|
||||||
UnarmedManager unarmedManager = new UnarmedManager(attacker);
|
UnarmedManager unarmedManager = new UnarmedManager(player);
|
||||||
unarmedManager.bonusDamage(event);
|
unarmedManager.bonusDamage(event);
|
||||||
unarmedManager.berserkDamage(event);
|
unarmedManager.berserkDamage(event);
|
||||||
unarmedManager.disarmCheck(target);
|
unarmedManager.disarmCheck(target);
|
||||||
|
|
||||||
startGainXp(attacker, unarmedManager.getProfile(), target, SkillType.UNARMED);
|
startGainXp(player, unarmedManager.getProfile(), target, SkillType.UNARMED);
|
||||||
}
|
}
|
||||||
else if (heldItemType == Material.BONE && target instanceof Tameable) {
|
else if (heldItemType == Material.BONE && target instanceof Tameable) {
|
||||||
TamingManager tamingManager = new TamingManager(attacker);
|
TamingManager tamingManager = new TamingManager(player);
|
||||||
tamingManager.beastLore(target);
|
tamingManager.beastLore(target);
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
break;
|
Entity damager = event.getDamager();
|
||||||
|
|
||||||
|
switch (damager.getType()) {
|
||||||
case WOLF:
|
case WOLF:
|
||||||
Wolf wolf = (Wolf) event.getDamager();
|
Wolf wolf = (Wolf) damager;
|
||||||
|
|
||||||
if (wolf.isTamed() && wolf.getOwner() instanceof Player) {
|
if (wolf.isTamed() && wolf.getOwner() instanceof Player) {
|
||||||
Player master = (Player) wolf.getOwner();
|
Player master = (Player) wolf.getOwner();
|
||||||
@ -158,7 +159,7 @@ public class Combat {
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case ARROW:
|
case ARROW:
|
||||||
LivingEntity shooter = ((Arrow) event.getDamager()).getShooter();
|
LivingEntity shooter = ((Arrow) damager).getShooter();
|
||||||
|
|
||||||
//TODO: Is there a reason we're breaking here instead of returning?
|
//TODO: Is there a reason we're breaking here instead of returning?
|
||||||
if (shooter == null || shooter.getType() != EntityType.PLAYER) {
|
if (shooter == null || shooter.getType() != EntityType.PLAYER) {
|
||||||
@ -184,10 +185,10 @@ public class Combat {
|
|||||||
if (targetIsPlayer) {
|
if (targetIsPlayer) {
|
||||||
Player player = (Player) target;
|
Player player = (Player) target;
|
||||||
|
|
||||||
if (event.getDamager() instanceof Player) {
|
if (damager instanceof Player) {
|
||||||
if (Swords.pvpEnabled) {
|
if (Swords.pvpEnabled) {
|
||||||
SwordsManager swordsManager = new SwordsManager(player);
|
SwordsManager swordsManager = new SwordsManager(player);
|
||||||
swordsManager.counterAttackChecks((LivingEntity) event.getDamager(), event.getDamage());
|
swordsManager.counterAttackChecks((LivingEntity) damager, event.getDamage());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Acrobatics.pvpEnabled) {
|
if (Acrobatics.pvpEnabled) {
|
||||||
@ -201,13 +202,13 @@ public class Combat {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if (Swords.pveEnabled && event.getDamager() instanceof LivingEntity) {
|
if (Swords.pveEnabled && damager instanceof LivingEntity) {
|
||||||
SwordsManager swordsManager = new SwordsManager(player);
|
SwordsManager swordsManager = new SwordsManager(player);
|
||||||
swordsManager.counterAttackChecks((LivingEntity) event.getDamager(), event.getDamage());
|
swordsManager.counterAttackChecks((LivingEntity) damager, event.getDamage());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Acrobatics.pveEnabled) {
|
if (Acrobatics.pveEnabled) {
|
||||||
if (!(event.getDamager() instanceof LightningStrike && Acrobatics.dodgeLightningDisabled)) {
|
if (!(damager instanceof LightningStrike && Acrobatics.dodgeLightningDisabled)) {
|
||||||
AcrobaticsManager acrobaticsManager = new AcrobaticsManager(player);
|
AcrobaticsManager acrobaticsManager = new AcrobaticsManager(player);
|
||||||
acrobaticsManager.dodgeCheck(event);
|
acrobaticsManager.dodgeCheck(event);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user