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

@@ -459,7 +459,7 @@ public class EnergySeeds extends AbstractNpcAI
return super.onEnterZone(character, zone);
}
if (character instanceof L2PcInstance)
if (character.isPlayer())
{
switch (zone.getId())
{

View File

@@ -1456,7 +1456,7 @@ public class SeedOfDestruction extends AbstractNpcAI
@Override
public String onEnterZone(L2Character character, L2ZoneType zone)
{
if (character instanceof L2PcInstance)
if (character.isPlayer())
{
final InstanceWorld tmpworld = InstanceManager.getInstance().getWorld(character);
if (tmpworld instanceof SODWorld)

View File

@@ -86,7 +86,7 @@ public final class Anais extends AbstractNpcAI
if ((_current != null) || (_pot < 4))
{
final L2Object target = npc.getTarget();
_nextTarget = target instanceof L2PcInstance ? (L2PcInstance) target : null;
_nextTarget = (target != null) && target.isPlayer() ? (L2PcInstance) target : null;
final L2Npc b = _divineBurners.get(_pot);
_pot = _pot + 1;
b.setDisplayEffect(1);

View File

@@ -195,7 +195,7 @@ public final class AdminCHSiege implements IAdminCommandHandler
{
BuilderUtil.sendSysMessage(activeChar, "You must target a clan member of the attacker!");
}
else if (!(rawTarget instanceof L2PcInstance))
else if (!rawTarget.isPlayer())
{
BuilderUtil.sendSysMessage(activeChar, "You must target a player with clan!");
}
@@ -250,7 +250,7 @@ public final class AdminCHSiege implements IAdminCommandHandler
{
BuilderUtil.sendSysMessage(activeChar, "You must target a clan member of the attacker!");
}
else if (!(rawTarget instanceof L2PcInstance))
else if (!rawTarget.isPlayer())
{
BuilderUtil.sendSysMessage(activeChar, "You must target a player with clan!");
}

View File

@@ -24,6 +24,7 @@ import com.l2jmobius.commons.database.DatabaseFactory;
import com.l2jmobius.gameserver.data.xml.impl.AdminData;
import com.l2jmobius.gameserver.handler.IAdminCommandHandler;
import com.l2jmobius.gameserver.model.L2AccessLevel;
import com.l2jmobius.gameserver.model.L2Object;
import com.l2jmobius.gameserver.model.L2World;
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
import com.l2jmobius.gameserver.network.Disconnection;
@@ -49,13 +50,14 @@ public final class AdminChangeAccessLevel implements IAdminCommandHandler
try
{
final int lvl = Integer.parseInt(parts[1]);
if (activeChar.getTarget() instanceof L2PcInstance)
final L2Object target = activeChar.getTarget();
if ((target == null) || !target.isPlayer())
{
onlineChange(activeChar, (L2PcInstance) activeChar.getTarget(), lvl);
activeChar.sendPacket(SystemMessageId.INVALID_TARGET);
}
else
{
activeChar.sendPacket(SystemMessageId.INVALID_TARGET);
onlineChange(activeChar, (L2PcInstance) target, lvl);
}
}
catch (Exception e)

View File

@@ -201,15 +201,12 @@ public class AdminClan implements IAdminCommandHandler
else
{
final L2Object targetObj = activeChar.getTarget();
if (targetObj instanceof L2PcInstance)
{
player = targetObj.getActingPlayer();
}
else
if ((targetObj == null) || !targetObj.isPlayer())
{
activeChar.sendPacket(SystemMessageId.INVALID_TARGET);
return null;
}
player = targetObj.getActingPlayer();
}
return player;
}

View File

@@ -20,6 +20,7 @@ import java.util.StringTokenizer;
import com.l2jmobius.gameserver.datatables.ItemTable;
import com.l2jmobius.gameserver.handler.IAdminCommandHandler;
import com.l2jmobius.gameserver.model.L2Object;
import com.l2jmobius.gameserver.model.L2World;
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
import com.l2jmobius.gameserver.model.items.L2Item;
@@ -116,12 +117,8 @@ public class AdminCreateItem implements IAdminCommandHandler
{
try
{
L2PcInstance target;
if (activeChar.getTarget() instanceof L2PcInstance)
{
target = (L2PcInstance) activeChar.getTarget();
}
else
final L2Object target = activeChar.getTarget();
if ((target == null) || !target.isPlayer())
{
BuilderUtil.sendSysMessage(activeChar, "Invalid target.");
return false;
@@ -135,13 +132,13 @@ public class AdminCreateItem implements IAdminCommandHandler
final int idval = Integer.parseInt(id);
final String num = st.nextToken();
final long numval = Long.parseLong(num);
createItem(activeChar, target, idval, numval);
createItem(activeChar, (L2PcInstance) target, idval, numval);
}
else if (st.countTokens() == 1)
{
final String id = st.nextToken();
final int idval = Integer.parseInt(id);
createItem(activeChar, target, idval, 1);
createItem(activeChar, (L2PcInstance) target, idval, 1);
}
}
catch (StringIndexOutOfBoundsException e)

View File

@@ -205,7 +205,7 @@ public class AdminCursedWeapons implements IAdminCommandHandler
else
{
final L2Object target = activeChar.getTarget();
if (target instanceof L2PcInstance)
if ((target != null) && target.isPlayer())
{
((L2PcInstance) target).addItem("AdminCursedWeaponAdd", id, 1, target, true);
}

View File

@@ -53,7 +53,7 @@ public class AdminDisconnect implements IAdminCommandHandler
{
final L2Object target = activeChar.getTarget();
L2PcInstance player = null;
if (target instanceof L2PcInstance)
if ((target != null) && target.isPlayer())
{
player = (L2PcInstance) target;
}

View File

@@ -119,7 +119,7 @@ public class AdminEditChar implements IAdminCommandHandler
{
showCharacterInfo(activeChar, L2World.getInstance().getPlayer(data[1]));
}
else if (activeChar.getTarget() instanceof L2PcInstance)
else if ((activeChar.getTarget() != null) && activeChar.getTarget().isPlayer())
{
showCharacterInfo(activeChar, activeChar.getTarget().getActingPlayer());
}
@@ -192,7 +192,7 @@ public class AdminEditChar implements IAdminCommandHandler
{
editCharacter(activeChar, data[1]);
}
else if (activeChar.getTarget() instanceof L2PcInstance)
else if ((activeChar.getTarget() != null) && activeChar.getTarget().isPlayer())
{
editCharacter(activeChar, null);
}
@@ -230,7 +230,7 @@ public class AdminEditChar implements IAdminCommandHandler
final String val = command.substring(12);
final int pk = Integer.parseInt(val);
final L2Object target = activeChar.getTarget();
if (target instanceof L2PcInstance)
if ((target != null) && target.isPlayer())
{
final L2PcInstance player = (L2PcInstance) target;
player.setPkKills(pk);
@@ -261,7 +261,7 @@ public class AdminEditChar implements IAdminCommandHandler
final String val = command.substring(13);
final int pvp = Integer.parseInt(val);
final L2Object target = activeChar.getTarget();
if (target instanceof L2PcInstance)
if ((target != null) && target.isPlayer())
{
final L2PcInstance player = (L2PcInstance) target;
player.setPvpKills(pvp);
@@ -292,7 +292,7 @@ public class AdminEditChar implements IAdminCommandHandler
final String val = command.substring(14);
final int fame = Integer.parseInt(val);
final L2Object target = activeChar.getTarget();
if (target instanceof L2PcInstance)
if ((target != null) && target.isPlayer())
{
final L2PcInstance player = (L2PcInstance) target;
player.setFame(fame);
@@ -323,7 +323,7 @@ public class AdminEditChar implements IAdminCommandHandler
final String val = command.substring(10);
final int recVal = Integer.parseInt(val);
final L2Object target = activeChar.getTarget();
if (target instanceof L2PcInstance)
if ((target != null) && target.isPlayer())
{
final L2PcInstance player = (L2PcInstance) target;
player.setRecomHave(recVal);
@@ -355,7 +355,7 @@ public class AdminEditChar implements IAdminCommandHandler
final int classidval = Integer.parseInt(val);
final L2Object target = activeChar.getTarget();
L2PcInstance player = null;
if (target instanceof L2PcInstance)
if ((target != null) && target.isPlayer())
{
player = (L2PcInstance) target;
}
@@ -452,7 +452,7 @@ public class AdminEditChar implements IAdminCommandHandler
final String val = command.substring(15);
final L2Object target = activeChar.getTarget();
L2PcInstance player = null;
if (target instanceof L2PcInstance)
if ((target != null) && target.isPlayer())
{
player = (L2PcInstance) target;
}
@@ -476,7 +476,7 @@ public class AdminEditChar implements IAdminCommandHandler
final String val = command.substring(17);
final L2Object target = activeChar.getTarget();
L2PcInstance player = null;
if (target instanceof L2PcInstance)
if ((target != null) && target.isPlayer())
{
player = (L2PcInstance) target;
}
@@ -523,7 +523,7 @@ public class AdminEditChar implements IAdminCommandHandler
{
final L2Object target = activeChar.getTarget();
L2PcInstance player = null;
if (target instanceof L2PcInstance)
if ((target != null) && target.isPlayer())
{
player = (L2PcInstance) target;
}
@@ -546,7 +546,7 @@ public class AdminEditChar implements IAdminCommandHandler
final String val = command.substring(15);
final L2Object target = activeChar.getTarget();
L2PcInstance player = null;
if (target instanceof L2PcInstance)
if ((target != null) && target.isPlayer())
{
player = (L2PcInstance) target;
}
@@ -570,7 +570,7 @@ public class AdminEditChar implements IAdminCommandHandler
final String val = command.substring(16);
final L2Object target = activeChar.getTarget();
L2PcInstance player = null;
if (target instanceof L2PcInstance)
if ((target != null) && target.isPlayer())
{
player = (L2PcInstance) target;
}
@@ -695,7 +695,7 @@ public class AdminEditChar implements IAdminCommandHandler
else
{
final L2Object target = activeChar.getTarget();
if (target instanceof L2PcInstance)
if ((target != null) && target.isPlayer())
{
pl = (L2PcInstance) target;
}
@@ -832,7 +832,7 @@ public class AdminEditChar implements IAdminCommandHandler
target = activeChar.getTarget();
}
if (target instanceof L2PcInstance)
if ((target != null) && target.isPlayer())
{
if (((L2PcInstance) target).isInParty())
{
@@ -856,7 +856,7 @@ public class AdminEditChar implements IAdminCommandHandler
{
player = activeChar;
}
else if ((activeChar.getTarget() != null) && (activeChar.getTarget() instanceof L2PcInstance))
else if ((activeChar.getTarget() != null) && (activeChar.getTarget().isPlayer()))
{
player = (L2PcInstance) activeChar.getTarget();
}
@@ -991,7 +991,7 @@ public class AdminEditChar implements IAdminCommandHandler
if (player == null)
{
final L2Object target = activeChar.getTarget();
if (target instanceof L2PcInstance)
if ((target != null) && target.isPlayer())
{
player = (L2PcInstance) target;
}
@@ -1095,7 +1095,7 @@ public class AdminEditChar implements IAdminCommandHandler
// function to change karma of selected char
final L2Object target = activeChar.getTarget();
L2PcInstance player = null;
if (target instanceof L2PcInstance)
if ((target != null) && target.isPlayer())
{
player = (L2PcInstance) target;
}
@@ -1136,7 +1136,7 @@ public class AdminEditChar implements IAdminCommandHandler
target = activeChar.getTarget();
}
if (target instanceof L2PcInstance)
if ((target != null) && target.isPlayer())
{
final L2PcInstance player = (L2PcInstance) target;
gatherCharacterInfo(activeChar, player, "charedit.htm");

View File

@@ -633,7 +633,7 @@ public class AdminEffects implements IAdminCommandHandler
activeChar.sendPacket(SystemMessageId.NOTHING_HAPPENED);
return false;
}
if ((target instanceof L2PcInstance) && ((action < 2) || ((action > 18) && (action != SocialAction.LEVEL_UP))))
if (target.isPlayer() && ((action < 2) || ((action > 18) && (action != SocialAction.LEVEL_UP))))
{
activeChar.sendPacket(SystemMessageId.NOTHING_HAPPENED);
return false;

View File

@@ -118,7 +118,7 @@ public class AdminElement implements IAdminCommandHandler
target = activeChar;
}
L2PcInstance player = null;
if (target instanceof L2PcInstance)
if (target.isPlayer())
{
player = (L2PcInstance) target;
}

View File

@@ -178,7 +178,7 @@ public class AdminEnchant implements IAdminCommandHandler
target = activeChar;
}
L2PcInstance player = null;
if (target instanceof L2PcInstance)
if (target.isPlayer())
{
player = (L2PcInstance) target;
}

View File

@@ -385,7 +385,7 @@ public class AdminEventEngine implements IAdminCommandHandler
}
else
{
if ((activeChar.getTarget() != null) && (activeChar.getTarget() instanceof L2PcInstance))
if ((activeChar.getTarget() != null) && (activeChar.getTarget().isPlayer()))
{
L2Event.removeAndResetPlayer((L2PcInstance) activeChar.getTarget());
}

View File

@@ -90,7 +90,7 @@ public class AdminExpSp implements IAdminCommandHandler
{
final L2Object target = activeChar.getTarget();
L2PcInstance player = null;
if (target instanceof L2PcInstance)
if ((target != null) && target.isPlayer())
{
player = (L2PcInstance) target;
}
@@ -113,7 +113,7 @@ public class AdminExpSp implements IAdminCommandHandler
{
final L2Object target = activeChar.getTarget();
L2PcInstance player = null;
if (target instanceof L2PcInstance)
if ((target != null) && target.isPlayer())
{
player = (L2PcInstance) target;
}
@@ -156,7 +156,7 @@ public class AdminExpSp implements IAdminCommandHandler
{
final L2Object target = activeChar.getTarget();
L2PcInstance player = null;
if (target instanceof L2PcInstance)
if ((target != null) && target.isPlayer())
{
player = (L2PcInstance) target;
}

View File

@@ -74,7 +74,7 @@ public class AdminFortSiege implements IAdminCommandHandler
{
final L2Object target = activeChar.getTarget();
L2PcInstance player = null;
if (target instanceof L2PcInstance)
if ((target != null) && target.isPlayer())
{
player = (L2PcInstance) target;
}

View File

@@ -78,7 +78,7 @@ public class AdminGmChat implements IAdminCommandHandler
activeChar.sendPacket(SystemMessageId.SELECT_TARGET);
return;
}
if (!(target instanceof L2PcInstance))
if (!target.isPlayer())
{
activeChar.sendPacket(SystemMessageId.INVALID_TARGET);
return;

View File

@@ -96,7 +96,7 @@ public class AdminHeal implements IAdminCommandHandler
L2World.getInstance().forEachVisibleObject(activeChar, L2Character.class, character ->
{
character.setCurrentHpMp(character.getMaxHp(), character.getMaxMp());
if (character instanceof L2PcInstance)
if (character.isPlayer())
{
character.setCurrentCp(character.getMaxCp());
}
@@ -118,7 +118,7 @@ public class AdminHeal implements IAdminCommandHandler
{
final L2Character target = (L2Character) obj;
target.setCurrentHpMp(target.getMaxHp(), target.getMaxMp());
if (target instanceof L2PcInstance)
if (target.isPlayer())
{
target.setCurrentCp(target.getMaxCp());
}

View File

@@ -114,7 +114,7 @@ public class AdminInstance implements IAdminCommandHandler
return false;
}
target.setInstanceId(val);
if (target instanceof L2PcInstance)
if (target.isPlayer())
{
final L2PcInstance player = (L2PcInstance) target;
player.sendMessage("Admin set your instance to:" + val);

View File

@@ -95,7 +95,7 @@ public class AdminInstanceZone implements IAdminCommandHandler
}
else if (activeChar.getTarget() != null)
{
if (activeChar.getTarget() instanceof L2PcInstance)
if (activeChar.getTarget().isPlayer())
{
display((L2PcInstance) activeChar.getTarget(), activeChar);
}

View File

@@ -45,7 +45,7 @@ public class AdminInvul implements IAdminCommandHandler
if (command.equals("admin_setinvul"))
{
final L2Object target = activeChar.getTarget();
if (target instanceof L2PcInstance)
if ((target != null) && target.isPlayer())
{
handleInvul((L2PcInstance) target);
}

View File

@@ -124,7 +124,7 @@ public class AdminKill implements IAdminCommandHandler
private void kill(L2PcInstance activeChar, L2Character target)
{
if (target instanceof L2PcInstance)
if (target.isPlayer())
{
if (!((L2PcInstance) target).isGM())
{

View File

@@ -65,7 +65,7 @@ public class AdminLevel implements IAdminCommandHandler
{
try
{
if (!(targetChar instanceof L2PcInstance))
if ((targetChar == null) || !targetChar.isPlayer())
{
activeChar.sendPacket(SystemMessageId.THAT_IS_AN_INCORRECT_TARGET); // incorrect target!
return false;

View File

@@ -233,7 +233,7 @@ public class AdminMenu implements IAdminCommandHandler
}
if (target != null)
{
if (target instanceof L2PcInstance)
if (target.isPlayer())
{
target.reduceCurrentHp(target.getMaxHp() + target.getMaxCp() + 1, activeChar, null);
filename = "charmanage.htm";
@@ -267,7 +267,7 @@ public class AdminMenu implements IAdminCommandHandler
private void teleportToCharacter(L2PcInstance activeChar, L2Object target)
{
L2PcInstance player = null;
if (target instanceof L2PcInstance)
if ((target != null) && target.isPlayer())
{
player = (L2PcInstance) target;
}

View File

@@ -102,7 +102,7 @@ public class AdminPetition implements IAdminCommandHandler
try
{
final L2Object targetChar = activeChar.getTarget();
if ((targetChar == null) || !(targetChar instanceof L2PcInstance))
if ((targetChar == null) || !targetChar.isPlayer())
{
activeChar.sendPacket(SystemMessageId.THAT_IS_AN_INCORRECT_TARGET);
return false;

View File

@@ -51,7 +51,7 @@ public class AdminPledge implements IAdminCommandHandler
{
final L2Object target = activeChar.getTarget();
L2PcInstance player = null;
if (target instanceof L2PcInstance)
if ((target != null) && target.isPlayer())
{
player = (L2PcInstance) target;
}

View File

@@ -141,7 +141,7 @@ public class AdminRes implements IAdminCommandHandler
L2World.getInstance().forEachVisibleObjectInRange(activeChar, L2Character.class, radius, knownChar ->
{
if (!(knownChar instanceof L2PcInstance) && !(knownChar instanceof L2ControllableMobInstance))
if (!knownChar.isPlayer() && !(knownChar instanceof L2ControllableMobInstance))
{
doResurrect(knownChar);
}
@@ -156,9 +156,9 @@ public class AdminRes implements IAdminCommandHandler
return;
}
if ((obj instanceof L2PcInstance) || (obj instanceof L2ControllableMobInstance))
if ((obj == null) || (obj.isPlayer()) || (obj instanceof L2ControllableMobInstance))
{
activeChar.sendPacket(SystemMessageId.INVALID_TARGET);
activeChar.sendPacket(SystemMessageId.INCORRECT_ITEM);
return;
}
@@ -173,7 +173,7 @@ public class AdminRes implements IAdminCommandHandler
}
// If the target is a player, then restore the XP lost on death.
if (targetChar instanceof L2PcInstance)
if (targetChar.isPlayer())
{
((L2PcInstance) targetChar).restoreExp(100.0);
}

View File

@@ -132,7 +132,7 @@ public class AdminRide implements IAdminCommandHandler
{
L2PcInstance player = null;
if ((activeChar.getTarget() == null) || (activeChar.getTarget().getObjectId() == activeChar.getObjectId()) || !(activeChar.getTarget() instanceof L2PcInstance))
if ((activeChar.getTarget() == null) || (activeChar.getTarget().getObjectId() == activeChar.getObjectId()) || !activeChar.getTarget().isPlayer())
{
player = activeChar;
}

View File

@@ -272,7 +272,7 @@ public class AdminTeleport implements IAdminCommandHandler
else
{
final L2Object target = activeChar.getTarget();
if (target instanceof L2PcInstance)
if ((target != null) && target.isPlayer())
{
teleportHome(target.getActingPlayer());
}
@@ -369,7 +369,7 @@ public class AdminTeleport implements IAdminCommandHandler
{
final L2Object target = activeChar.getTarget();
L2PcInstance player = null;
if (target instanceof L2PcInstance)
if ((target != null) && target.isPlayer())
{
player = (L2PcInstance) target;
}
@@ -389,7 +389,7 @@ public class AdminTeleport implements IAdminCommandHandler
{
final L2Object target = activeChar.getTarget();
L2PcInstance player = null;
if (target instanceof L2PcInstance)
if ((target != null) && target.isPlayer())
{
player = (L2PcInstance) target;
}
@@ -464,7 +464,7 @@ public class AdminTeleport implements IAdminCommandHandler
}
L2PcInstance player = null;
if (target instanceof L2PcInstance)
if (target.isPlayer())
{
player = (L2PcInstance) target;
}

View File

@@ -44,7 +44,7 @@ public class AdminTvTEvent implements IAdminCommandHandler
{
final L2Object target = activeChar.getTarget();
if (!(target instanceof L2PcInstance))
if ((target == null) || !target.isPlayer())
{
BuilderUtil.sendSysMessage(activeChar, "You should select a player!");
return true;
@@ -56,7 +56,7 @@ public class AdminTvTEvent implements IAdminCommandHandler
{
final L2Object target = activeChar.getTarget();
if (!(target instanceof L2PcInstance))
if ((target == null) || !target.isPlayer())
{
BuilderUtil.sendSysMessage(activeChar, "You should select a player!");
return true;

View File

@@ -59,7 +59,7 @@ public class AdminVitality implements IAdminCommandHandler
final StringTokenizer st = new StringTokenizer(command, " ");
final String cmd = st.nextToken();
if (activeChar.getTarget() instanceof L2PcInstance)
if ((activeChar.getTarget() != null) && activeChar.getTarget().isPlayer())
{
L2PcInstance target;
target = (L2PcInstance) activeChar.getTarget();

View File

@@ -73,7 +73,7 @@ public final class EnergyAttack extends AbstractEffect
@Override
public void onStart(BuffInfo info)
{
final L2PcInstance attacker = info.getEffector() instanceof L2PcInstance ? (L2PcInstance) info.getEffector() : null;
final L2PcInstance attacker = info.getEffector().isPlayer() ? (L2PcInstance) info.getEffector() : null;
if (attacker == null)
{
return;
@@ -137,14 +137,14 @@ public final class EnergyAttack extends AbstractEffect
attack *= energyChargesBoost;
attack *= weaponTypeBoost;
if (target instanceof L2PcInstance)
if (target.isPlayer())
{
defence *= target.getStat().calcStat(Stats.PVP_PHYS_SKILL_DEF, 1.0);
}
damage = attack / defence;
damage *= damageMultiplier;
if (target instanceof L2PcInstance)
if (target.isPlayer())
{
damage *= attacker.getStat().calcStat(Stats.PVP_PHYS_SKILL_DMG, 1.0);
damage = attacker.getStat().calcStat(Stats.PHYSICAL_SKILL_POWER, damage);

View File

@@ -55,7 +55,7 @@ public final class GiveRecommendation extends AbstractEffect
@Override
public void onStart(BuffInfo info)
{
final L2PcInstance target = info.getEffected() instanceof L2PcInstance ? (L2PcInstance) info.getEffected() : null;
final L2PcInstance target = (info.getEffected() != null) && info.getEffected().isPlayer() ? (L2PcInstance) info.getEffected() : null;
if (target != null)
{
int recommendationsGiven = _amount;
@@ -80,7 +80,7 @@ public final class GiveRecommendation extends AbstractEffect
}
else
{
final L2PcInstance player = info.getEffector() instanceof L2PcInstance ? (L2PcInstance) info.getEffector() : null;
final L2PcInstance player = (info.getEffector() != null) && info.getEffector().isPlayer() ? (L2PcInstance) info.getEffector() : null;
if (player != null)
{
player.sendPacket(SystemMessageId.NOTHING_HAPPENED);

View File

@@ -31,7 +31,7 @@ public class Bypass implements IItemHandler
@Override
public boolean useItem(L2Playable playable, L2ItemInstance item, boolean forceUse)
{
if (!(playable instanceof L2PcInstance))
if (!playable.isPlayer())
{
return false;
}

View File

@@ -138,7 +138,7 @@ public class Wedding implements IVoicedCommandHandler
activeChar.sendMessage("You have no one targeted.");
return false;
}
else if (!(activeChar.getTarget() instanceof L2PcInstance))
else if (!activeChar.getTarget().isPlayer())
{
activeChar.sendMessage("You can only ask another player to engage you.");
return false;

View File

@@ -2012,7 +2012,7 @@ public final class CrystalCaverns extends AbstractInstance
@Override
public String onEnterZone(L2Character character, L2ZoneType zone)
{
if (character instanceof L2PcInstance)
if (character.isPlayer())
{
final InstanceWorld tmpworld = InstanceManager.getInstance().getWorld(character);
if (tmpworld instanceof CCWorld)
@@ -2079,7 +2079,7 @@ public final class CrystalCaverns extends AbstractInstance
@Override
public String onExitZone(L2Character character, L2ZoneType zone)
{
if (character instanceof L2PcInstance)
if (character.isPlayer())
{
final InstanceWorld tmpworld = InstanceManager.getInstance().getWorld(character);
if (tmpworld instanceof CCWorld)

View File

@@ -461,7 +461,7 @@ public final class NornilsGarden extends AbstractInstance
@Override
public String onEnterZone(L2Character character, L2ZoneType zone)
{
if ((character instanceof L2PcInstance) && !character.isDead() && !character.isTeleporting() && ((L2PcInstance) character).isOnline())
if (character.isPlayer() && !character.isDead() && !character.isTeleporting() && ((L2PcInstance) character).isOnline())
{
final InstanceWorld tmpworld = InstanceManager.getInstance().getWorld(character);
if (tmpworld instanceof NornilsWorld)

View File

@@ -868,7 +868,7 @@ public class Q00144_PailakaInjuredDragon extends Quest
@Override
public String onEnterZone(L2Character character, L2ZoneType zone)
{
if ((character instanceof L2PcInstance) && !character.isDead() && !character.isTeleporting() && ((L2PcInstance) character).isOnline())
if (character.isPlayer() && !character.isDead() && !character.isTeleporting() && ((L2PcInstance) character).isOnline())
{
final InstanceWorld world = InstanceManager.getInstance().getWorld(character);
if ((world != null) && (world.getTemplateId() == INSTANCE_ID))

View File

@@ -207,7 +207,7 @@ public class TerritoryWarSuperClass extends Quest
@Override
public String onDeath(L2Character killer, L2Character victim, QuestState qs)
{
if ((killer == victim) || !(victim instanceof L2PcInstance) || (victim.getLevel() < 61))
if ((killer == victim) || !victim.isPlayer() || (victim.getLevel() < 61))
{
return "";
}

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);
}