Code improvements.

This commit is contained in:
MobiusDev
2016-04-24 16:30:15 +00:00
parent 8bd51aba1c
commit 2dd14bef9b
860 changed files with 8865 additions and 17041 deletions

View File

@@ -74,12 +74,7 @@ public class Area implements ITargetTypeHandler
final Collection<L2Character> objs = activeChar.getKnownList().getKnownCharacters();
for (L2Character obj : objs)
{
if (!(obj.isAttackable() || obj.isPlayable()))
{
continue;
}
if (obj == origin)
if (!(obj.isAttackable() || obj.isPlayable()) || (obj == origin))
{
continue;
}
@@ -100,12 +95,7 @@ public class Area implements ITargetTypeHandler
}
}
if (targetList.isEmpty())
{
return EMPTY_TARGET_LIST;
}
return targetList.toArray(new L2Character[targetList.size()]);
return targetList.isEmpty() ? EMPTY_TARGET_LIST : targetList.toArray(new L2Character[targetList.size()]);
}
@Override

View File

@@ -71,11 +71,7 @@ public class AreaCorpseMob implements ITargetTypeHandler
targetList.add(obj);
}
if (targetList.isEmpty())
{
return EMPTY_TARGET_LIST;
}
return targetList.toArray(new L2Character[targetList.size()]);
return targetList.isEmpty() ? EMPTY_TARGET_LIST : targetList.toArray(new L2Character[targetList.size()]);
}
@Override

View File

@@ -93,11 +93,7 @@ public class AreaFriendly implements ITargetTypeHandler
Collections.sort(targetList, CHAR_COMPARATOR);
}
if (targetList.isEmpty())
{
return EMPTY_TARGET_LIST;
}
return targetList.toArray(new L2Character[targetList.size()]);
return targetList.isEmpty() ? EMPTY_TARGET_LIST : targetList.toArray(new L2Character[targetList.size()]);
}
private boolean checkTarget(L2PcInstance activeChar, L2Character target)

View File

@@ -42,15 +42,12 @@ public class AreaSummon implements ITargetTypeHandler
return EMPTY_TARGET_LIST;
}
if (onlyFirst)
if (onlyFirst && activeChar.hasSummon())
{
if (activeChar.hasSummon())
return new L2Character[]
{
return new L2Character[]
{
activeChar.getServitors().values().stream().findFirst().orElse(activeChar.getPet())
};
}
activeChar.getServitors().values().stream().findFirst().orElse(activeChar.getPet())
};
}
final boolean srcInArena = (activeChar.isInsideZone(ZoneId.PVP) && !activeChar.isInsideZone(ZoneId.SIEGE));
@@ -87,12 +84,7 @@ public class AreaSummon implements ITargetTypeHandler
targetList.add(obj);
}
if (targetList.isEmpty())
{
return EMPTY_TARGET_LIST;
}
return targetList.toArray(new L2Character[targetList.size()]);
return targetList.isEmpty() ? EMPTY_TARGET_LIST : targetList.toArray(new L2Character[targetList.size()]);
}
@Override

View File

@@ -43,13 +43,9 @@ public class Aura implements ITargetTypeHandler
if (obj.isDoor() || obj.isAttackable() || obj.isPlayable())
{
// Stealth door targeting.
if (obj.isDoor())
if (obj.isDoor() && !((L2DoorInstance) obj).getTemplate().isStealth())
{
final L2DoorInstance door = (L2DoorInstance) obj;
if (!door.getTemplate().isStealth())
{
continue;
}
continue;
}
if (!Skill.checkForAreaOffensiveSkills(activeChar, obj, skill, srcInArena))

View File

@@ -55,12 +55,7 @@ public class AuraFriendly implements ITargetTypeHandler
targetList.add(obj);
}
if (targetList.isEmpty())
{
return EMPTY_TARGET_LIST;
}
return targetList.toArray(new L2Character[targetList.size()]);
return targetList.isEmpty() ? EMPTY_TARGET_LIST : targetList.toArray(new L2Character[targetList.size()]);
}
private boolean checkTarget(L2PcInstance activeChar, L2Character target)

View File

@@ -105,12 +105,7 @@ public class BehindArea implements ITargetTypeHandler
}
}
if (targetList.isEmpty())
{
return EMPTY_TARGET_LIST;
}
return targetList.toArray(new L2Character[targetList.size()]);
return targetList.isEmpty() ? EMPTY_TARGET_LIST : targetList.toArray(new L2Character[targetList.size()]);
}
@Override

View File

@@ -105,12 +105,7 @@ public class FrontArea implements ITargetTypeHandler
}
}
if (targetList.isEmpty())
{
return EMPTY_TARGET_LIST;
}
return targetList.toArray(new L2Character[targetList.size()]);
return targetList.isEmpty() ? EMPTY_TARGET_LIST : targetList.toArray(new L2Character[targetList.size()]);
}
@Override

View File

@@ -63,12 +63,9 @@ public class Ground implements ITargetTypeHandler
}
}
if (targetList.isEmpty())
if (targetList.isEmpty() && skill.hasEffectType(L2EffectType.SUMMON_NPC))
{
if (skill.hasEffectType(L2EffectType.SUMMON_NPC))
{
targetList.add(activeChar);
}
targetList.add(activeChar);
}
return targetList.isEmpty() ? EMPTY_TARGET_LIST : targetList.toArray(new L2Character[targetList.size()]);
}

View File

@@ -36,15 +36,12 @@ public class PartyMember implements ITargetTypeHandler
activeChar.sendPacket(SystemMessageId.THAT_IS_AN_INCORRECT_TARGET);
return EMPTY_TARGET_LIST;
}
if (!target.isDead())
if (!target.isDead() && ((target == activeChar) || (activeChar.isInParty() && target.isInParty() && (activeChar.getParty().getLeaderObjectId() == target.getParty().getLeaderObjectId())) || ((activeChar.isPlayer() && target.isSummon() && ((activeChar.getPet() == target) || activeChar.hasServitor(target.getObjectId()))) || (activeChar.isSummon() && target.isPlayer() && ((activeChar == target.getPet()) || target.hasServitor(activeChar.getObjectId()))))))
{
if ((target == activeChar) || (activeChar.isInParty() && target.isInParty() && (activeChar.getParty().getLeaderObjectId() == target.getParty().getLeaderObjectId())) || ((activeChar.isPlayer() && target.isSummon() && ((activeChar.getPet() == target) || activeChar.hasServitor(target.getObjectId()))) || (activeChar.isSummon() && target.isPlayer() && ((activeChar == target.getPet()) || target.hasServitor(activeChar.getObjectId())))))
return new L2Character[]
{
return new L2Character[]
{
target
};
}
target
};
}
return EMPTY_TARGET_LIST;
}

View File

@@ -40,39 +40,32 @@ public class PartyNotMe implements ITargetTypeHandler
final int radius = skill.getAffectRange();
if (activeChar.getParty() != null)
{
final List<L2PcInstance> partyList = activeChar.getParty().getMembers();
for (L2PcInstance partyMember : partyList)
for (L2PcInstance partyMember : activeChar.getParty().getMembers())
{
if (partyMember == activeChar)
if ((partyMember == activeChar) || !Util.checkIfInRange(Config.ALT_PARTY_RANGE, activeChar, partyMember, true))
{
continue;
}
else if (!Util.checkIfInRange(Config.ALT_PARTY_RANGE, activeChar, partyMember, true))
if (Skill.addPet(activeChar, partyMember, radius, false))
{
continue;
targetList.add(partyMember.getPet());
}
else
partyMember.getServitors().values().forEach(s ->
{
if (Skill.addPet(activeChar, partyMember, radius, false))
if (Skill.addCharacter(activeChar, s, radius, false))
{
targetList.add(partyMember.getPet());
targetList.add(s);
}
partyMember.getServitors().values().forEach(s ->
{
if (Skill.addCharacter(activeChar, s, radius, false))
{
targetList.add(s);
}
});
if (Skill.addCharacter(activeChar, partyMember, radius, false))
{
targetList.add(partyMember);
}
});
if (Skill.addCharacter(activeChar, partyMember, radius, false))
{
targetList.add(partyMember);
}
targetList.add(partyMember);
}
}
return targetList.toArray(new L2Character[targetList.size()]);

View File

@@ -75,17 +75,10 @@ public class PcBody implements ITargetTypeHandler
{
boolean condGood = true;
if (skill.hasEffectType(L2EffectType.RESURRECTION))
if (skill.hasEffectType(L2EffectType.RESURRECTION) && (targetPlayer != null) && targetPlayer.isInsideZone(ZoneId.SIEGE) && !targetPlayer.isInSiege())
{
if (targetPlayer != null)
{
// check target is not in a active siege zone
if (targetPlayer.isInsideZone(ZoneId.SIEGE) && !targetPlayer.isInSiege())
{
condGood = false;
activeChar.sendPacket(SystemMessageId.IT_IS_NOT_POSSIBLE_TO_RESURRECT_IN_BATTLEGROUNDS_WHERE_A_SIEGE_WAR_IS_TAKING_PLACE);
}
}
condGood = false;
activeChar.sendPacket(SystemMessageId.IT_IS_NOT_POSSIBLE_TO_RESURRECT_IN_BATTLEGROUNDS_WHERE_A_SIEGE_WAR_IS_TAKING_PLACE);
}
if (condGood)

View File

@@ -34,25 +34,25 @@ public class Summon implements ITargetTypeHandler
@Override
public L2Object[] getTargetList(Skill skill, L2Character activeChar, boolean onlyFirst, L2Character target)
{
if (activeChar.hasSummon())
if (!activeChar.hasSummon())
{
if (!activeChar.hasPet() && activeChar.hasServitors())
{
return activeChar.getServitors().values().toArray(new L2Character[0]);
}
else if (activeChar.hasPet() && !activeChar.hasServitors())
{
return new L2Character[]
{
activeChar.getPet()
};
}
final List<L2Character> targets = new ArrayList<>(1 + activeChar.getServitors().size());
targets.add(activeChar.getPet());
targets.addAll(activeChar.getServitors().values());
return targets.toArray(new L2Character[0]);
return EMPTY_TARGET_LIST;
}
return EMPTY_TARGET_LIST;
if (!activeChar.hasPet() && activeChar.hasServitors())
{
return activeChar.getServitors().values().toArray(new L2Character[0]);
}
if (activeChar.hasPet() && !activeChar.hasServitors())
{
return new L2Character[]
{
activeChar.getPet()
};
}
final List<L2Character> targets = new ArrayList<>(1 + activeChar.getServitors().size());
targets.add(activeChar.getPet());
targets.addAll(activeChar.getServitors().values());
return targets.toArray(new L2Character[0]);
}
@Override