Replaced instanceof L2PcInstance with isPlayer method.

This commit is contained in:
MobiusDev
2018-07-01 00:13:23 +00:00
parent 0259b6527c
commit 5934fac571
365 changed files with 828 additions and 835 deletions

View File

@@ -542,7 +542,7 @@ public abstract class AbstractAI implements Ctrl
*/
protected void clientActionFailed()
{
if (_actor instanceof L2PcInstance)
if (_actor.isPlayer())
{
_actor.sendPacket(ActionFailed.STATIC_PACKET);
}
@@ -768,7 +768,7 @@ public abstract class AbstractAI implements Ctrl
}
return;
}
if (_actor instanceof L2PcInstance)
if (_actor.isPlayer())
{
if (!AttackStanceTaskManager.getInstance().hasAttackStanceTask(_actor) && isAutoAttacking())
{

View File

@@ -262,7 +262,7 @@ public class L2AttackableAI extends L2CharacterAI
}
// Check if the L2PcInstance target has karma (=PK)
if ((target instanceof L2PcInstance) && (((L2PcInstance) target).getKarma() > 0))
if (target.isPlayer() && (((L2PcInstance) target).getKarma() > 0))
{
return GeoEngine.getInstance().canSeeTarget(me, target); // Los Check
}
@@ -555,7 +555,7 @@ public class L2AttackableAI extends L2CharacterAI
/*
* Check to see if this is a festival mob spawn. If it is, then check to see if the aggro trigger is a festival participant...if so, move to attack it.
*/
if ((npc instanceof L2FestivalMonsterInstance) && (target instanceof L2PcInstance))
if ((npc instanceof L2FestivalMonsterInstance) && target.isPlayer())
{
final L2PcInstance targetPlayer = (L2PcInstance) target;
@@ -1938,7 +1938,7 @@ public class L2AttackableAI extends L2CharacterAI
continue;
}
if (((obj instanceof L2PcInstance) || (obj instanceof L2Summon)) && (dist2 <= range) && !getAttackTarget().isAffectedBySkill(sk.getId()))
if ((obj.isPlayer() || (obj instanceof L2Summon)) && (dist2 <= range) && !getAttackTarget().isAffectedBySkill(sk.getId()))
{
return obj;
}
@@ -2010,7 +2010,7 @@ public class L2AttackableAI extends L2CharacterAI
continue;
}
if (((obj instanceof L2PcInstance) || (obj instanceof L2Summon)) && (dist2 <= range) && (getAttackTarget().getEffectList().getFirstEffect(L2EffectType.BUFF) != null))
if ((obj.isPlayer() || (obj instanceof L2Summon)) && (dist2 <= range) && (getAttackTarget().getEffectList().getFirstEffect(L2EffectType.BUFF) != null))
{
return obj;
}
@@ -2075,7 +2075,7 @@ public class L2AttackableAI extends L2CharacterAI
{
continue;
}
if (obj instanceof L2PcInstance)
if (obj.isPlayer())
{
return obj;
}
@@ -2143,7 +2143,7 @@ public class L2AttackableAI extends L2CharacterAI
{
return;
}
if (obj instanceof L2PcInstance)
if (obj.isPlayer())
{
actor.addDamageHate(obj, 0, MostHate != null ? actor.getHating(MostHate) : 2000);
actor.setTarget(obj);
@@ -2216,7 +2216,7 @@ public class L2AttackableAI extends L2CharacterAI
{
return;
}
if (obj instanceof L2PcInstance)
if (obj.isPlayer())
{
actor.addDamageHate(obj, 0, (MostHate != null) && !MostHate.isDead() ? actor.getHating(MostHate) : 2000);
actor.setTarget(obj);

View File

@@ -1095,7 +1095,7 @@ public class L2CharacterAI extends AbstractAI
if ((target == null) || target.isAlikeDead())
{
// check if player is fakedeath
if ((target instanceof L2PcInstance) && ((L2PcInstance) target).isFakeDeath())
if ((target != null) && target.isPlayer() && ((L2PcInstance) target).isFakeDeath())
{
target.stopFakeDeath(true);
return false;
@@ -1125,7 +1125,7 @@ public class L2CharacterAI extends AbstractAI
*/
protected boolean checkTargetLost(L2Object target)
{
if ((target instanceof L2PcInstance) && ((L2PcInstance) target).isFakeDeath())
if ((target != null) && target.isPlayer() && ((L2PcInstance) target).isFakeDeath())
{
((L2PcInstance) target).stopFakeDeath(true);
return false;

View File

@@ -127,7 +127,7 @@ public class L2FortSiegeGuardAI extends L2CharacterAI implements Runnable
if ((target == null) || (target instanceof L2DefenderInstance) || (target instanceof L2NpcInstance) || (target instanceof L2DoorInstance) || target.isAlikeDead() || (target instanceof L2FortCommanderInstance) || (target instanceof L2Playable))
{
L2PcInstance player = null;
if (target instanceof L2PcInstance)
if ((target != null) && target.isPlayer())
{
player = (L2PcInstance) target;
}
@@ -357,7 +357,7 @@ public class L2FortSiegeGuardAI extends L2CharacterAI implements Runnable
{
if (!(cha instanceof L2Npc))
{
if (_selfAnalysis.hasHealOrResurrect && (cha instanceof L2PcInstance) && ((L2Npc) _actor).getFort().getSiege().checkIsDefender(((L2PcInstance) cha).getClan())//
if (_selfAnalysis.hasHealOrResurrect && cha.isPlayer() && ((L2Npc) _actor).getFort().getSiege().checkIsDefender(((L2PcInstance) cha).getClan())//
&& !_actor.isAttackingDisabled() && (cha.getCurrentHp() < (cha.getMaxHp() * 0.6)) && (_actor.getCurrentHp() > (_actor.getMaxHp() / 2)) && (_actor.getCurrentMp() > (_actor.getMaxMp() / 2)) && cha.isInCombat())
{
for (Skill sk : _selfAnalysis.healSkills)
@@ -458,7 +458,7 @@ public class L2FortSiegeGuardAI extends L2CharacterAI implements Runnable
}
// never attack defenders
if ((attackTarget instanceof L2PcInstance) && sGuard.getFort().getSiege().checkIsDefender(((L2PcInstance) attackTarget).getClan()))
if (attackTarget.isPlayer() && sGuard.getFort().getSiege().checkIsDefender(((L2PcInstance) attackTarget).getClan()))
{
// Cancel the target
sGuard.stopHating(attackTarget);

View File

@@ -250,7 +250,7 @@ public class L2PlayerAI extends L2PlayableAI
private void thinkCast()
{
final L2Character target = getCastTarget();
if ((_skill.getTargetType() == L2TargetType.GROUND) && (_actor instanceof L2PcInstance))
if ((_skill.getTargetType() == L2TargetType.GROUND) && _actor.isPlayer())
{
if (maybeMoveToPosition(((L2PcInstance) _actor).getCurrentSkillWorldPosition(), _actor.getMagicalAttackRange(_skill)))
{

View File

@@ -355,7 +355,7 @@ public class L2SiegeGuardAI extends L2CharacterAI implements Runnable
{
if (!(cha instanceof L2Npc))
{
if (_selfAnalysis.hasHealOrResurrect && (cha instanceof L2PcInstance) && (((L2Npc) _actor).getCastle().getSiege().checkIsDefender(((L2PcInstance) cha).getClan()))//
if (_selfAnalysis.hasHealOrResurrect && cha.isPlayer() && (((L2Npc) _actor).getCastle().getSiege().checkIsDefender(((L2PcInstance) cha).getClan()))//
&& !_actor.isAttackingDisabled() && (cha.getCurrentHp() < (cha.getMaxHp() * 0.6)) && (_actor.getCurrentHp() > (_actor.getMaxHp() / 2)) && (_actor.getCurrentMp() > (_actor.getMaxMp() / 2)) && cha.isInCombat())
{
for (Skill sk : _selfAnalysis.healSkills)
@@ -457,7 +457,7 @@ public class L2SiegeGuardAI extends L2CharacterAI implements Runnable
}
// never attack defenders
if ((attackTarget instanceof L2PcInstance) && (sGuard.getConquerableHall() == null) && sGuard.getCastle().getSiege().checkIsDefender(((L2PcInstance) attackTarget).getClan()))
if (attackTarget.isPlayer() && (sGuard.getConquerableHall() == null) && sGuard.getCastle().getSiege().checkIsDefender(((L2PcInstance) attackTarget).getClan()))
{
// Cancel the target
sGuard.stopHating(attackTarget);

View File

@@ -890,7 +890,7 @@ public class L2Attackable extends L2Npc
return 0;
}
if (ai.getAttacker() instanceof L2PcInstance)
if (ai.getAttacker().isPlayer())
{
final L2PcInstance act = (L2PcInstance) ai.getAttacker();
if (act.isInvisible() || act.isInvul() || act.isSpawnProtected())

View File

@@ -772,7 +772,7 @@ public abstract class L2Summon extends L2Playable
}
}
if (_owner.isInOlympiadMode() && (target instanceof L2PcInstance) && ((L2PcInstance) target).isInOlympiadMode() && (((L2PcInstance) target).getOlympiadGameId() == _owner.getOlympiadGameId()))
if (_owner.isInOlympiadMode() && target.isPlayer() && ((L2PcInstance) target).isInOlympiadMode() && (((L2PcInstance) target).getOlympiadGameId() == _owner.getOlympiadGameId()))
{
OlympiadGameManager.getInstance().notifyCompetitorDamage(getOwner(), damage);
}

View File

@@ -107,7 +107,7 @@ public class L2BlockInstance extends L2MonsterInstance
@Override
public boolean isAutoAttackable(L2Character attacker)
{
if (attacker instanceof L2PcInstance)
if (attacker.isPlayer())
{
return (attacker.getActingPlayer() != null) && (attacker.getActingPlayer().getBlockCheckerArena() > -1);
}

View File

@@ -92,7 +92,7 @@ public class L2FestivalMonsterInstance extends L2MonsterInstance
{
L2PcInstance killingChar = null;
if (!(lastAttacker instanceof L2PcInstance))
if (!lastAttacker.isPlayer())
{
return;
}

View File

@@ -54,7 +54,7 @@ public class L2FortCommanderInstance extends L2DefenderInstance
@Override
public boolean isAutoAttackable(L2Character attacker)
{
if ((attacker == null) || !(attacker instanceof L2PcInstance))
if ((attacker == null) || !attacker.isPlayer())
{
return false;
}

View File

@@ -40,7 +40,7 @@ public class L2FriendlyMobInstance extends L2Attackable
@Override
public boolean isAutoAttackable(L2Character attacker)
{
if (attacker instanceof L2PcInstance)
if (attacker.isPlayer())
{
return ((L2PcInstance) attacker).getKarma() > 0;
}

View File

@@ -69,7 +69,7 @@ public final class L2GrandBossInstance extends L2MonsterInstance
}
L2PcInstance player = null;
if (killer instanceof L2PcInstance)
if (killer.isPlayer())
{
player = (L2PcInstance) killer;
}

View File

@@ -4224,7 +4224,12 @@ public final class L2PcInstance extends L2Playable
*/
public void doInteract(L2Character target)
{
if (target instanceof L2PcInstance)
if (target == null)
{
return;
}
if (target.isPlayer())
{
final L2PcInstance temp = (L2PcInstance) target;
sendPacket(ActionFailed.STATIC_PACKET);
@@ -4242,8 +4247,7 @@ public final class L2PcInstance extends L2Playable
sendPacket(new RecipeShopSellList(this, temp));
}
}
// _interactTarget=null should never happen but one never knows ^^;
else if (target != null)
else // _interactTarget=null should never happen but one never knows ^^;
{
target.onAction(this);
}
@@ -5368,7 +5372,7 @@ public final class L2PcInstance extends L2Playable
*/
public void increasePvpKills(L2Character target)
{
if ((target instanceof L2PcInstance) && AntiFeedManager.getInstance().check(this, target))
if (target.isPlayer() && AntiFeedManager.getInstance().check(this, target))
{
setPvpKills(_pvpKills + 1);

View File

@@ -75,7 +75,7 @@ public final class L2QuestGuardInstance extends L2GuardInstance
@Override
public void addDamageHate(L2Character attacker, int damage, int aggro)
{
if (!_isPassive && !(attacker instanceof L2PcInstance))
if (!_isPassive && !attacker.isPlayer())
{
super.addDamageHate(attacker, damage, aggro);
}
@@ -89,7 +89,7 @@ public final class L2QuestGuardInstance extends L2GuardInstance
@Override
public boolean isAutoAttackable(L2Character attacker)
{
return _isAutoAttackable && !(attacker instanceof L2PcInstance);
return _isAutoAttackable && !attacker.isPlayer();
}
@Override

View File

@@ -133,7 +133,7 @@ public final class L2TerritoryWardInstance extends L2Attackable
return false;
}
if (killer instanceof L2PcInstance)
if (killer.isPlayer())
{
if ((((L2PcInstance) killer).getSiegeSide() > 0) && !((L2PcInstance) killer).isCombatFlagEquipped())
{

View File

@@ -146,7 +146,7 @@ public final class L2TrapInstance extends L2Npc
return true;
}
if (cha instanceof L2PcInstance)
if (cha.isPlayer())
{
// observers can't see trap
if (((L2PcInstance) cha).inObserverMode())
@@ -321,7 +321,7 @@ public final class L2TrapInstance extends L2Npc
return;
}
if (_owner.isInOlympiadMode() && (target instanceof L2PcInstance) && ((L2PcInstance) target).isInOlympiadMode() && (((L2PcInstance) target).getOlympiadGameId() == _owner.getOlympiadGameId()))
if (_owner.isInOlympiadMode() && target.isPlayer() && ((L2PcInstance) target).isInOlympiadMode() && (((L2PcInstance) target).getOlympiadGameId() == _owner.getOlympiadGameId()))
{
OlympiadGameManager.getInstance().notifyCompetitorDamage(getOwner(), damage);
}

View File

@@ -159,7 +159,7 @@ public class PlayableStat extends CharStat
setExp(getExpForLevel(getLevel()));
}
if (!levelIncreased && (getActiveChar() instanceof L2PcInstance) && !getActiveChar().isGM() && Config.DECREASE_SKILL_LEVEL)
if (!levelIncreased && getActiveChar().isPlayer() && !getActiveChar().isGM() && Config.DECREASE_SKILL_LEVEL)
{
((L2PcInstance) getActiveChar()).checkPlayerSkills();
}

View File

@@ -92,7 +92,7 @@ public final class ConditionSiegeZone extends Condition
*/
public static boolean checkIfOk(L2Character activeChar, Castle castle, int value)
{
if ((activeChar == null) || !(activeChar instanceof L2PcInstance))
if ((activeChar == null) || !activeChar.isPlayer())
{
return false;
}
@@ -138,7 +138,7 @@ public final class ConditionSiegeZone extends Condition
*/
public static boolean checkIfOk(L2Character activeChar, Fort fort, int value)
{
if ((activeChar == null) || !(activeChar instanceof L2PcInstance))
if ((activeChar == null) || !activeChar.isPlayer())
{
return false;
}

View File

@@ -42,13 +42,16 @@ public class ConditionTargetAggro extends Condition
@Override
public boolean testImpl(L2Character effector, L2Character effected, Skill skill, L2Item item)
{
if (effected instanceof L2MonsterInstance)
if (effected != null)
{
return ((L2MonsterInstance) effected).isAggressive() == _isAggro;
}
if (effected instanceof L2PcInstance)
{
return ((L2PcInstance) effected).getKarma() > 0;
if (effected instanceof L2MonsterInstance)
{
return ((L2MonsterInstance) effected).isAggressive() == _isAggro;
}
if (effected.isPlayer())
{
return ((L2PcInstance) effected).getKarma() > 0;
}
}
return false;
}

View File

@@ -826,7 +826,7 @@ public class TvTEvent
return;
}
}
else if (killerCharacter instanceof L2PcInstance)
else if (killerCharacter.isPlayer())
{
killerPlayerInstance = (L2PcInstance) killerCharacter;
}

View File

@@ -269,7 +269,7 @@ public abstract class Inventory extends ItemContainer
@Override
public void notifyUnequiped(int slot, L2ItemInstance item, Inventory inventory)
{
if (!(inventory.getOwner() instanceof L2PcInstance))
if (!inventory.getOwner().isPlayer())
{
return;
}
@@ -388,7 +388,7 @@ public abstract class Inventory extends ItemContainer
@Override
public void notifyEquiped(int slot, L2ItemInstance item, Inventory inventory)
{
if (!(inventory.getOwner() instanceof L2PcInstance))
if (!inventory.getOwner().isPlayer())
{
return;
}
@@ -486,7 +486,7 @@ public abstract class Inventory extends ItemContainer
@Override
public void notifyEquiped(int slot, L2ItemInstance item, Inventory inventory)
{
if (!(inventory.getOwner() instanceof L2PcInstance))
if (!inventory.getOwner().isPlayer())
{
return;
}
@@ -612,7 +612,7 @@ public abstract class Inventory extends ItemContainer
@Override
public void notifyUnequiped(int slot, L2ItemInstance item, Inventory inventory)
{
if (!(inventory.getOwner() instanceof L2PcInstance))
if (!inventory.getOwner().isPlayer())
{
return;
}
@@ -1308,7 +1308,7 @@ public abstract class Inventory extends ItemContainer
try
{
unEquipItemInSlot(slot);
if (getOwner() instanceof L2PcInstance)
if (getOwner().isPlayer())
{
((L2PcInstance) getOwner()).refreshExpertisePenalty();
}
@@ -1451,7 +1451,7 @@ public abstract class Inventory extends ItemContainer
final L2ItemInstance old = setPaperdollItem(pdollSlot, null);
if (old != null)
{
if (getOwner() instanceof L2PcInstance)
if (getOwner().isPlayer())
{
((L2PcInstance) getOwner()).refreshExpertisePenalty();
}
@@ -1488,13 +1488,13 @@ public abstract class Inventory extends ItemContainer
*/
public void equipItem(L2ItemInstance item)
{
if ((getOwner() instanceof L2PcInstance) && (((L2PcInstance) getOwner()).getPrivateStoreType() != PrivateStoreType.NONE))
{
return;
}
if (getOwner() instanceof L2PcInstance)
if (getOwner().isPlayer())
{
if (((L2PcInstance) getOwner()).getPrivateStoreType() != PrivateStoreType.NONE)
{
return;
}
final L2PcInstance player = (L2PcInstance) getOwner();
if (!player.canOverrideCond(PcCondOverride.ITEM_CONDITIONS) && !player.isHero() && item.isHeroItem())
@@ -1808,7 +1808,7 @@ public abstract class Inventory extends ItemContainer
continue;
}
if (getOwner() instanceof L2PcInstance)
if (getOwner().isPlayer())
{
final L2PcInstance player = (L2PcInstance) getOwner();

View File

@@ -31,7 +31,6 @@ import com.l2jmobius.gameserver.model.PcCondOverride;
import com.l2jmobius.gameserver.model.StatsSet;
import com.l2jmobius.gameserver.model.actor.L2Character;
import com.l2jmobius.gameserver.model.actor.L2Summon;
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
import com.l2jmobius.gameserver.model.conditions.Condition;
import com.l2jmobius.gameserver.model.events.ListenersContainer;
import com.l2jmobius.gameserver.model.holders.SkillHolder;
@@ -802,7 +801,7 @@ public abstract class L2Item extends ListenersContainer implements IIdentifiable
}
// Don't allow hero equipment and restricted items during Olympiad
if ((isOlyRestrictedItem() || _heroItem) && (activeChar instanceof L2PcInstance) && activeChar.getActingPlayer().isInOlympiadMode())
if ((isOlyRestrictedItem() || _heroItem) && activeChar.isPlayer() && activeChar.getActingPlayer().isInOlympiadMode())
{
if (isEquipable())
{

View File

@@ -20,7 +20,6 @@ import com.l2jmobius.gameserver.model.L2World;
import com.l2jmobius.gameserver.model.StatsSet;
import com.l2jmobius.gameserver.model.actor.L2Character;
import com.l2jmobius.gameserver.model.actor.L2Npc;
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
import com.l2jmobius.gameserver.model.conditions.Condition;
import com.l2jmobius.gameserver.model.conditions.ConditionGameChance;
import com.l2jmobius.gameserver.model.events.EventDispatcher;
@@ -414,7 +413,7 @@ public final class L2Weapon extends L2Item
onMagicSkill.activateSkill(caster, target);
// notify quests of a skill use
if (caster instanceof L2PcInstance)
if (caster.isPlayer())
{
final L2Character[] targets =
{

View File

@@ -569,7 +569,7 @@ public final class QuestState
*/
public void addNotifyOfDeath(L2Character character)
{
if (!(character instanceof L2PcInstance))
if (!character.isPlayer())
{
return;
}

View File

@@ -220,7 +220,7 @@ public abstract class L2ZoneType extends ListenersContainer
return false;
}
if (character instanceof L2PcInstance)
if (character.isPlayer())
{
// Check class type
if (_classType != 0)

View File

@@ -17,7 +17,6 @@
package com.l2jmobius.gameserver.model.zone.type;
import com.l2jmobius.gameserver.model.actor.L2Character;
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
import com.l2jmobius.gameserver.model.zone.L2ZoneType;
import com.l2jmobius.gameserver.model.zone.ZoneId;
import com.l2jmobius.gameserver.network.SystemMessageId;
@@ -36,7 +35,7 @@ public class L2ArenaZone extends L2ZoneType
@Override
protected void onEnter(L2Character character)
{
if (character instanceof L2PcInstance)
if (character.isPlayer())
{
if (!character.isInsideZone(ZoneId.PVP))
{
@@ -50,7 +49,7 @@ public class L2ArenaZone extends L2ZoneType
@Override
protected void onExit(L2Character character)
{
if (character instanceof L2PcInstance)
if (character.isPlayer())
{
if (!character.isInsideZone(ZoneId.PVP))
{

View File

@@ -124,7 +124,7 @@ public final class Broadcast
*/
public static void toSelfAndKnownPlayers(L2Character character, IClientOutgoingPacket mov)
{
if (character instanceof L2PcInstance)
if (character.isPlayer())
{
character.sendPacket(mov);
}
@@ -140,7 +140,7 @@ public final class Broadcast
radius = 600;
}
if (character instanceof L2PcInstance)
if (character.isPlayer())
{
character.sendPacket(mov);
}