Replaced instanceof L2NpcInstance with isNpc method.

This commit is contained in:
MobiusDev
2018-07-02 01:27:50 +00:00
parent b33537aa50
commit 5f62a4c740
37 changed files with 37 additions and 137 deletions

View File

@@ -40,7 +40,7 @@ public class SkillList implements IBypassHandler
@Override
public boolean useBypass(String command, L2PcInstance activeChar, L2Character target)
{
if (!(target instanceof L2NpcInstance))
if ((target == null) || !target.isNpc())
{
return false;
}

View File

@@ -32,7 +32,6 @@ import com.l2jmobius.gameserver.model.actor.L2Npc;
import com.l2jmobius.gameserver.model.actor.L2Playable;
import com.l2jmobius.gameserver.model.actor.instance.L2ControllableMobInstance;
import com.l2jmobius.gameserver.model.actor.instance.L2DoorInstance;
import com.l2jmobius.gameserver.model.actor.instance.L2NpcInstance;
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
import com.l2jmobius.gameserver.model.skills.Skill;
import com.l2jmobius.gameserver.util.Util;
@@ -372,7 +371,7 @@ public final class L2ControllableMobAI extends L2AttackableAI
private boolean checkAutoAttackCondition(L2Character target)
{
if ((target == null) || (target instanceof L2NpcInstance) || (target instanceof L2DoorInstance))
if ((target == null) || target.isNpc() || (target instanceof L2DoorInstance))
{
return false;
}

View File

@@ -37,7 +37,6 @@ import com.l2jmobius.gameserver.model.actor.L2Summon;
import com.l2jmobius.gameserver.model.actor.instance.L2DefenderInstance;
import com.l2jmobius.gameserver.model.actor.instance.L2DoorInstance;
import com.l2jmobius.gameserver.model.actor.instance.L2FortCommanderInstance;
import com.l2jmobius.gameserver.model.actor.instance.L2NpcInstance;
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
import com.l2jmobius.gameserver.model.effects.L2EffectType;
import com.l2jmobius.gameserver.model.skills.Skill;
@@ -129,7 +128,7 @@ public class L2FortSiegeGuardAI extends L2CharacterAI implements Runnable
}
// Check if the target isn't another guard, folk or a door
if ((target instanceof L2DefenderInstance) || (target instanceof L2NpcInstance) || (target instanceof L2DoorInstance) || target.isAlikeDead() || (target instanceof L2FortCommanderInstance) || target.isPlayable())
if ((target instanceof L2DefenderInstance) || target.isNpc() || (target instanceof L2DoorInstance) || target.isAlikeDead() || (target instanceof L2FortCommanderInstance) || target.isPlayable())
{
L2PcInstance player = null;
if (target.isPlayer())

View File

@@ -36,7 +36,6 @@ import com.l2jmobius.gameserver.model.actor.L2Playable;
import com.l2jmobius.gameserver.model.actor.L2Summon;
import com.l2jmobius.gameserver.model.actor.instance.L2DefenderInstance;
import com.l2jmobius.gameserver.model.actor.instance.L2DoorInstance;
import com.l2jmobius.gameserver.model.actor.instance.L2NpcInstance;
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
import com.l2jmobius.gameserver.model.effects.L2EffectType;
import com.l2jmobius.gameserver.model.skills.Skill;
@@ -124,7 +123,7 @@ public class L2SiegeGuardAI extends L2CharacterAI implements Runnable
protected boolean autoAttackCondition(L2Character target)
{
// Check if the target isn't another guard, folk or a door
if ((target == null) || (target instanceof L2DefenderInstance) || (target instanceof L2NpcInstance) || (target instanceof L2DoorInstance) || target.isAlikeDead())
if ((target == null) || (target instanceof L2DefenderInstance) || target.isNpc() || (target instanceof L2DoorInstance) || target.isAlikeDead())
{
return false;
}

View File

@@ -38,7 +38,6 @@ import com.l2jmobius.gameserver.model.L2Object;
import com.l2jmobius.gameserver.model.L2Party;
import com.l2jmobius.gameserver.model.L2World;
import com.l2jmobius.gameserver.model.Location;
import com.l2jmobius.gameserver.model.actor.instance.L2NpcInstance;
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
import com.l2jmobius.gameserver.model.actor.stat.SummonStat;
import com.l2jmobius.gameserver.model.actor.status.SummonStatus;
@@ -779,7 +778,7 @@ public abstract class L2Summon extends L2Playable
final SystemMessage sm;
if (target.isInvul() && !(target instanceof L2NpcInstance))
if (target.isInvul() && !target.isNpc())
{
sm = SystemMessage.getSystemMessage(SystemMessageId.THE_ATTACK_HAS_BEEN_BLOCKED);
}

View File

@@ -325,7 +325,7 @@ public final class L2TrapInstance extends L2Npc
OlympiadGameManager.getInstance().notifyCompetitorDamage(getOwner(), damage);
}
if (target.isInvul() && !(target instanceof L2NpcInstance))
if (target.isInvul() && !target.isNpc())
{
_owner.sendPacket(SystemMessageId.THE_ATTACK_HAS_BEEN_BLOCKED);
}

View File

@@ -101,12 +101,7 @@ public final class RequestAcquireSkill implements IClientIncomingPacket
}
final L2Npc trainer = activeChar.getLastFolkNPC();
if (!(trainer instanceof L2NpcInstance))
{
return;
}
if (!trainer.canInteract(activeChar) && !activeChar.isGM())
if ((trainer == null) || !trainer.isNpc() || (!trainer.canInteract(activeChar) && !activeChar.isGM()))
{
return;
}

View File

@@ -22,7 +22,6 @@ import com.l2jmobius.gameserver.data.xml.impl.SkillTreesData;
import com.l2jmobius.gameserver.model.ClanPrivilege;
import com.l2jmobius.gameserver.model.L2SkillLearn;
import com.l2jmobius.gameserver.model.actor.L2Npc;
import com.l2jmobius.gameserver.model.actor.instance.L2NpcInstance;
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
import com.l2jmobius.gameserver.model.base.AcquireSkillType;
import com.l2jmobius.gameserver.model.skills.Skill;
@@ -64,12 +63,7 @@ public final class RequestAcquireSkillInfo implements IClientIncomingPacket
}
final L2Npc trainer = activeChar.getLastFolkNPC();
if (!(trainer instanceof L2NpcInstance))
{
return;
}
if (!trainer.canInteract(activeChar) && !activeChar.isGM())
if ((trainer == null) || !trainer.isNpc() || (!trainer.canInteract(activeChar) && !activeChar.isGM()))
{
return;
}

View File

@@ -26,7 +26,6 @@ import com.l2jmobius.gameserver.model.actor.L2Character;
import com.l2jmobius.gameserver.model.actor.L2Npc;
import com.l2jmobius.gameserver.model.actor.L2Summon;
import com.l2jmobius.gameserver.model.actor.instance.L2MonsterInstance;
import com.l2jmobius.gameserver.model.actor.instance.L2NpcInstance;
import com.l2jmobius.gameserver.model.actor.instance.L2TrapInstance;
import com.l2jmobius.gameserver.model.skills.AbnormalVisualEffect;
import com.l2jmobius.gameserver.model.zone.ZoneId;
@@ -126,7 +125,7 @@ public abstract class AbstractNpcInfo implements IClientOutgoingPacket
}
// npc crest of owning clan/ally of castle
if ((cha instanceof L2NpcInstance) && cha.isInsideZone(ZoneId.TOWN) && (Config.SHOW_CREST_WITHOUT_QUEST || cha.getCastle().getShowNpcCrest()) && (cha.getCastle().getOwnerId() != 0))
if (cha.isNpc() && cha.isInsideZone(ZoneId.TOWN) && (Config.SHOW_CREST_WITHOUT_QUEST || cha.getCastle().getShowNpcCrest()) && (cha.getCastle().getOwnerId() != 0))
{
final L2TownZone town = TownManager.getTown(_x, _y, _z);
if (town != null)