mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2024-11-23 05:36:46 +01:00
Optimizations to Combat.java
This commit is contained in:
parent
4407ed0a6f
commit
9040a2a2e3
@ -33,7 +33,7 @@ import com.gmail.nossr50.runnables.GainXp;
|
|||||||
import com.gmail.nossr50.skills.acrobatics.AcrobaticsManager;
|
import com.gmail.nossr50.skills.acrobatics.AcrobaticsManager;
|
||||||
import com.gmail.nossr50.skills.archery.ArcheryManager;
|
import com.gmail.nossr50.skills.archery.ArcheryManager;
|
||||||
import com.gmail.nossr50.skills.combat.Axes;
|
import com.gmail.nossr50.skills.combat.Axes;
|
||||||
import com.gmail.nossr50.skills.combat.Swords;
|
import com.gmail.nossr50.skills.swords.Swords;
|
||||||
import com.gmail.nossr50.skills.taming.TamingManager;
|
import com.gmail.nossr50.skills.taming.TamingManager;
|
||||||
import com.gmail.nossr50.skills.unarmed.UnarmedManager;
|
import com.gmail.nossr50.skills.unarmed.UnarmedManager;
|
||||||
|
|
||||||
@ -362,9 +362,6 @@ public class Combat {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
PlayerAnimationEvent armswing = new PlayerAnimationEvent(attacker);
|
|
||||||
mcMMO.p.getServer().getPluginManager().callEvent(armswing);
|
|
||||||
|
|
||||||
if (entity instanceof Player) {
|
if (entity instanceof Player) {
|
||||||
Player defender = (Player) entity;
|
Player defender = (Player) entity;
|
||||||
|
|
||||||
@ -386,16 +383,13 @@ public class Combat {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (entity instanceof Tameable) {
|
else if (!shouldBeAffected(attacker, target)) {
|
||||||
AnimalTamer tamer = ((Tameable) entity).getOwner();
|
continue;
|
||||||
|
|
||||||
if (tamer instanceof Player) {
|
|
||||||
if (tamer.equals(attacker) || PartyManager.getInstance().inSameParty(attacker, (Player) tamer)) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
PlayerAnimationEvent armswing = new PlayerAnimationEvent(attacker);
|
||||||
|
mcMMO.p.getServer().getPluginManager().callEvent(armswing);
|
||||||
|
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case SWORDS:
|
case SWORDS:
|
||||||
if (entity instanceof Player) {
|
if (entity instanceof Player) {
|
||||||
@ -523,4 +517,33 @@ public class Combat {
|
|||||||
mcMMO.p.getServer().getScheduler().scheduleSyncDelayedTask(mcMMO.p, new GainXp(attacker, PP, skillType, baseXP, target), 0);
|
mcMMO.p.getServer().getScheduler().scheduleSyncDelayedTask(mcMMO.p, new GainXp(attacker, PP, skillType, baseXP, target), 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check to see if the given LivingEntity should be affected by a combat ability.
|
||||||
|
*
|
||||||
|
* @param player The attacking Player
|
||||||
|
* @param livingEntity The defending LivingEntity
|
||||||
|
* @return true if the LivingEntity should be damaged, false otherwise.
|
||||||
|
*/
|
||||||
|
public static boolean shouldBeAffected(Player player, LivingEntity livingEntity) {
|
||||||
|
boolean isAffected = true;
|
||||||
|
|
||||||
|
if (livingEntity instanceof Tameable) {
|
||||||
|
Tameable pet = (Tameable) livingEntity;
|
||||||
|
|
||||||
|
if (pet.isTamed()) {
|
||||||
|
AnimalTamer tamer = pet.getOwner();
|
||||||
|
|
||||||
|
if (tamer instanceof Player) {
|
||||||
|
Player owner = (Player) tamer;
|
||||||
|
|
||||||
|
if (owner == player || PartyManager.getInstance().inSameParty(player, owner)) {
|
||||||
|
isAffected = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return isAffected;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user