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

@ -88,7 +88,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

@ -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

@ -22,6 +22,7 @@ import com.l2jmobius.gameserver.datatables.ItemTable;
import com.l2jmobius.gameserver.handler.IAdminCommandHandler;
import com.l2jmobius.gameserver.handler.IItemHandler;
import com.l2jmobius.gameserver.handler.ItemHandler;
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;
@ -123,12 +124,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;
@ -142,13 +139,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

@ -125,7 +125,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());
}
@ -198,7 +198,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);
}
@ -274,7 +274,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);
@ -304,7 +304,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);
@ -334,7 +334,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);
@ -460,7 +460,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;
}
@ -484,7 +484,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;
}
@ -535,7 +535,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;
}
@ -554,7 +554,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;
}
@ -578,7 +578,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;
}
@ -699,7 +699,7 @@ public class AdminEditChar implements IAdminCommandHandler
else
{
final L2Object target = activeChar.getTarget();
if (target instanceof L2PcInstance)
if ((target != null) && target.isPlayer())
{
pl = (L2PcInstance) target;
}
@ -836,7 +836,7 @@ public class AdminEditChar implements IAdminCommandHandler
target = activeChar.getTarget();
}
if (target instanceof L2PcInstance)
if (target.isPlayer())
{
if (((L2PcInstance) target).isInParty())
{
@ -856,14 +856,14 @@ public class AdminEditChar implements IAdminCommandHandler
else if (command.equals("admin_setnoble"))
{
L2PcInstance player = null;
if (activeChar.getTarget() == null)
{
player = activeChar;
}
else if ((activeChar.getTarget() != null) && (activeChar.getTarget() instanceof L2PcInstance))
if ((activeChar.getTarget() != null) && (activeChar.getTarget().isPlayer()))
{
player = (L2PcInstance) activeChar.getTarget();
}
else
{
player = activeChar;
}
if (player != null)
{
@ -1086,7 +1086,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;
}
@ -1218,7 +1218,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

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

View File

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

View File

@ -89,7 +89,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;
}
@ -112,7 +112,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;
}
@ -155,7 +155,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

@ -72,7 +72,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

@ -97,7 +97,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());
}
@ -119,7 +119,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

@ -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

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

View File

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

View File

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

View File

@ -231,7 +231,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";

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

@ -52,7 +52,7 @@ public class AdminPledge implements IAdminCommandHandler
final StringTokenizer st = new StringTokenizer(command);
final String cmd = st.nextToken();
final L2Object target = activeChar.getTarget();
final L2PcInstance targetPlayer = target instanceof L2PcInstance ? (L2PcInstance) target : null;
final L2PcInstance targetPlayer = (target != null) && target.isPlayer() ? (L2PcInstance) target : null;
L2Clan clan = targetPlayer != null ? targetPlayer.getClan() : null;
if (targetPlayer == null)
{

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,7 +156,7 @@ 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);
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

@ -131,7 +131,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

@ -295,7 +295,7 @@ public class AdminTeleport implements IAdminCommandHandler
else
{
final L2Object target = activeChar.getTarget();
if (target instanceof L2PcInstance)
if ((target != null) && target.isPlayer())
{
teleportHome(target.getActingPlayer());
}
@ -386,7 +386,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;
}
@ -406,7 +406,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;
}

View File

@ -56,7 +56,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())
{
final L2PcInstance target = (L2PcInstance) activeChar.getTarget();

View File

@ -53,7 +53,7 @@ public final class GiveRecommendation extends AbstractEffect
@Override
public void instant(L2Character effector, L2Character effected, Skill skill, L2ItemInstance item)
{
final L2PcInstance target = effected instanceof L2PcInstance ? (L2PcInstance) effected : null;
final L2PcInstance target = (effected != null) && effected.isPlayer() ? (L2PcInstance) effected : null;
if (target != null)
{
int recommendationsGiven = _amount;
@ -74,7 +74,7 @@ public final class GiveRecommendation extends AbstractEffect
}
else
{
final L2PcInstance player = effector instanceof L2PcInstance ? (L2PcInstance) effector : null;
final L2PcInstance player = (effector != null) && effector.isPlayer() ? (L2PcInstance) effector : 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

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

View File

@ -1045,7 +1045,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;
@ -1076,7 +1076,7 @@ public class L2CharacterAI extends AbstractAI
protected boolean checkTargetLost(L2Object target)
{
// check if player is fakedeath
if (target instanceof L2PcInstance)
if ((target != null) && target.isPlayer())
{
final L2PcInstance target2 = (L2PcInstance) target; // convert object to chara

View File

@ -269,7 +269,7 @@ public class L2PlayerAI extends L2PlayableAI
private void thinkCast()
{
final L2Object target = _skill.getTarget(_actor, _forceUse, _dontMove, false);
if ((_skill.getTargetType() == TargetType.GROUND) && (_actor instanceof L2PcInstance))
if ((_skill.getTargetType() == TargetType.GROUND) && _actor.isPlayer())
{
if (maybeMoveToPosition(((L2PcInstance) _actor).getCurrentSkillWorldPosition(), _actor.getMagicalAttackRange(_skill)))
{

View File

@ -919,7 +919,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

@ -714,7 +714,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

@ -103,7 +103,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

@ -50,7 +50,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

@ -4284,7 +4284,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 targetPlayer = (L2PcInstance) target;
sendPacket(ActionFailed.STATIC_PACKET);
@ -4302,7 +4307,7 @@ public final class L2PcInstance extends L2Playable
sendPacket(new RecipeShopSellList(this, targetPlayer));
}
}
else if (target != null) // _interactTarget=null should never happen but one never knows ^^;
else // _interactTarget=null should never happen but one never knows ^^;
{
target.onAction(this);
}

View File

@ -132,7 +132,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())
@ -260,7 +260,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

@ -175,7 +175,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

@ -81,7 +81,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;
}
@ -127,7 +127,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

@ -46,7 +46,7 @@ public class ConditionTargetAggro extends Condition
{
return ((L2MonsterInstance) effected).isAggressive() == _isAggro;
}
if (effected instanceof L2PcInstance)
if (effected.isPlayer())
{
return ((L2PcInstance) effected).getReputation() < 0;
}

View File

@ -386,7 +386,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;
}
@ -471,7 +471,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;
}
@ -594,7 +594,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;
}
@ -1468,13 +1468,13 @@ public abstract class Inventory extends ItemContainer
*/
public void equipItem(L2ItemInstance item)
{
if ((getOwner() instanceof L2PcInstance) && (((L2PcInstance) getOwner()).getPrivateStoreType() != PrivateStoreType.NONE))
{
return;
}
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())

View File

@ -22,7 +22,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.events.EventDispatcher;
import com.l2jmobius.gameserver.model.events.impl.character.npc.OnNpcSkillSee;
import com.l2jmobius.gameserver.model.items.type.WeaponType;
@ -288,7 +287,7 @@ public final class L2Weapon extends L2Item
if (type == ItemSkillType.ON_MAGIC_SKILL)
{
// notify quests of a skill use
if (caster instanceof L2PcInstance)
if (caster.isPlayer())
{
L2World.getInstance().forEachVisibleObjectInRange(caster, L2Npc.class, 1000, npc ->
{

View File

@ -231,7 +231,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

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

View File

@ -88,7 +88,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

@ -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

@ -22,6 +22,7 @@ import com.l2jmobius.gameserver.datatables.ItemTable;
import com.l2jmobius.gameserver.handler.IAdminCommandHandler;
import com.l2jmobius.gameserver.handler.IItemHandler;
import com.l2jmobius.gameserver.handler.ItemHandler;
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;
@ -123,12 +124,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;
@ -142,13 +139,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

@ -125,7 +125,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());
}
@ -198,7 +198,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);
}
@ -274,7 +274,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);
@ -304,7 +304,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);
@ -334,7 +334,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);
@ -460,7 +460,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;
}
@ -484,7 +484,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;
}
@ -535,7 +535,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;
}
@ -554,7 +554,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;
}
@ -578,7 +578,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;
}
@ -699,7 +699,7 @@ public class AdminEditChar implements IAdminCommandHandler
else
{
final L2Object target = activeChar.getTarget();
if (target instanceof L2PcInstance)
if ((target != null) && target.isPlayer())
{
pl = (L2PcInstance) target;
}
@ -836,7 +836,7 @@ public class AdminEditChar implements IAdminCommandHandler
target = activeChar.getTarget();
}
if (target instanceof L2PcInstance)
if (target.isPlayer())
{
if (((L2PcInstance) target).isInParty())
{
@ -856,14 +856,14 @@ public class AdminEditChar implements IAdminCommandHandler
else if (command.equals("admin_setnoble"))
{
L2PcInstance player = null;
if (activeChar.getTarget() == null)
{
player = activeChar;
}
else if ((activeChar.getTarget() != null) && (activeChar.getTarget() instanceof L2PcInstance))
if ((activeChar.getTarget() != null) && (activeChar.getTarget().isPlayer()))
{
player = (L2PcInstance) activeChar.getTarget();
}
else
{
player = activeChar;
}
if (player != null)
{
@ -1105,7 +1105,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;
}
@ -1238,7 +1238,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

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

View File

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

View File

@ -89,7 +89,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;
}
@ -112,7 +112,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;
}
@ -155,7 +155,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

@ -72,7 +72,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

@ -97,7 +97,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());
}
@ -119,7 +119,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

@ -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

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

View File

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

View File

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

View File

@ -231,7 +231,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";

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

@ -52,7 +52,7 @@ public class AdminPledge implements IAdminCommandHandler
final StringTokenizer st = new StringTokenizer(command);
final String cmd = st.nextToken();
final L2Object target = activeChar.getTarget();
final L2PcInstance targetPlayer = target instanceof L2PcInstance ? (L2PcInstance) target : null;
final L2PcInstance targetPlayer = (target != null) && target.isPlayer() ? (L2PcInstance) target : null;
L2Clan clan = targetPlayer != null ? targetPlayer.getClan() : null;
if (targetPlayer == null)
{

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,7 +156,7 @@ 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);
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

@ -131,7 +131,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

@ -295,7 +295,7 @@ public class AdminTeleport implements IAdminCommandHandler
else
{
final L2Object target = activeChar.getTarget();
if (target instanceof L2PcInstance)
if ((target != null) && target.isPlayer())
{
teleportHome(target.getActingPlayer());
}
@ -386,7 +386,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;
}
@ -406,7 +406,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;
}

View File

@ -56,7 +56,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())
{
final L2PcInstance target = (L2PcInstance) activeChar.getTarget();

View File

@ -53,7 +53,7 @@ public final class GiveRecommendation extends AbstractEffect
@Override
public void instant(L2Character effector, L2Character effected, Skill skill, L2ItemInstance item)
{
final L2PcInstance target = effected instanceof L2PcInstance ? (L2PcInstance) effected : null;
final L2PcInstance target = (effected != null) && effected.isPlayer() ? (L2PcInstance) effected : null;
if (target != null)
{
int recommendationsGiven = _amount;
@ -74,7 +74,7 @@ public final class GiveRecommendation extends AbstractEffect
}
else
{
final L2PcInstance player = effector instanceof L2PcInstance ? (L2PcInstance) effector : null;
final L2PcInstance player = (effector != null) && effector.isPlayer() ? (L2PcInstance) effector : 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

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

View File

@ -1045,7 +1045,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;
@ -1076,7 +1076,7 @@ public class L2CharacterAI extends AbstractAI
protected boolean checkTargetLost(L2Object target)
{
// check if player is fakedeath
if (target instanceof L2PcInstance)
if ((target != null) && target.isPlayer())
{
final L2PcInstance target2 = (L2PcInstance) target; // convert object to chara

View File

@ -269,7 +269,7 @@ public class L2PlayerAI extends L2PlayableAI
private void thinkCast()
{
final L2Object target = _skill.getTarget(_actor, _forceUse, _dontMove, false);
if ((_skill.getTargetType() == TargetType.GROUND) && (_actor instanceof L2PcInstance))
if ((_skill.getTargetType() == TargetType.GROUND) && _actor.isPlayer())
{
if (maybeMoveToPosition(((L2PcInstance) _actor).getCurrentSkillWorldPosition(), _actor.getMagicalAttackRange(_skill)))
{

View File

@ -915,7 +915,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

@ -714,7 +714,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

@ -103,7 +103,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

@ -50,7 +50,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

@ -4290,7 +4290,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 targetPlayer = (L2PcInstance) target;
sendPacket(ActionFailed.STATIC_PACKET);
@ -4308,7 +4313,7 @@ public final class L2PcInstance extends L2Playable
sendPacket(new RecipeShopSellList(this, targetPlayer));
}
}
else if (target != null) // _interactTarget=null should never happen but one never knows ^^;
else // _interactTarget=null should never happen but one never knows ^^;
{
target.onAction(this);
}

View File

@ -132,7 +132,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())
@ -260,7 +260,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

@ -175,7 +175,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

@ -81,7 +81,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;
}
@ -127,7 +127,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

@ -46,7 +46,7 @@ public class ConditionTargetAggro extends Condition
{
return ((L2MonsterInstance) effected).isAggressive() == _isAggro;
}
if (effected instanceof L2PcInstance)
if (effected.isPlayer())
{
return ((L2PcInstance) effected).getReputation() < 0;
}

View File

@ -394,7 +394,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;
}
@ -489,7 +489,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;
}
@ -618,7 +618,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;
}
@ -1498,13 +1498,13 @@ public abstract class Inventory extends ItemContainer
*/
public void equipItem(L2ItemInstance item)
{
if ((getOwner() instanceof L2PcInstance) && (((L2PcInstance) getOwner()).getPrivateStoreType() != PrivateStoreType.NONE))
{
return;
}
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())

View File

@ -22,7 +22,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.events.EventDispatcher;
import com.l2jmobius.gameserver.model.events.impl.character.npc.OnNpcSkillSee;
import com.l2jmobius.gameserver.model.items.type.WeaponType;
@ -288,7 +287,7 @@ public final class L2Weapon extends L2Item
if (type == ItemSkillType.ON_MAGIC_SKILL)
{
// notify quests of a skill use
if (caster instanceof L2PcInstance)
if (caster.isPlayer())
{
L2World.getInstance().forEachVisibleObjectInRange(caster, L2Npc.class, 1000, npc ->
{

View File

@ -231,7 +231,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

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

View File

@ -88,7 +88,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

@ -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

@ -22,6 +22,7 @@ import com.l2jmobius.gameserver.datatables.ItemTable;
import com.l2jmobius.gameserver.handler.IAdminCommandHandler;
import com.l2jmobius.gameserver.handler.IItemHandler;
import com.l2jmobius.gameserver.handler.ItemHandler;
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;
@ -123,12 +124,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;
@ -142,13 +139,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

@ -125,7 +125,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());
}
@ -198,7 +198,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);
}
@ -274,7 +274,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);
@ -304,7 +304,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);
@ -334,7 +334,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);
@ -460,7 +460,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;
}
@ -484,7 +484,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;
}
@ -535,7 +535,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;
}
@ -554,7 +554,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;
}
@ -578,7 +578,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;
}
@ -699,7 +699,7 @@ public class AdminEditChar implements IAdminCommandHandler
else
{
final L2Object target = activeChar.getTarget();
if (target instanceof L2PcInstance)
if ((target != null) && target.isPlayer())
{
pl = (L2PcInstance) target;
}
@ -836,7 +836,7 @@ public class AdminEditChar implements IAdminCommandHandler
target = activeChar.getTarget();
}
if (target instanceof L2PcInstance)
if (target.isPlayer())
{
if (((L2PcInstance) target).isInParty())
{
@ -856,14 +856,14 @@ public class AdminEditChar implements IAdminCommandHandler
else if (command.equals("admin_setnoble"))
{
L2PcInstance player = null;
if (activeChar.getTarget() == null)
{
player = activeChar;
}
else if ((activeChar.getTarget() != null) && (activeChar.getTarget() instanceof L2PcInstance))
if ((activeChar.getTarget() != null) && (activeChar.getTarget().isPlayer()))
{
player = (L2PcInstance) activeChar.getTarget();
}
else
{
player = activeChar;
}
if (player != null)
{
@ -1105,7 +1105,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;
}
@ -1238,7 +1238,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

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

View File

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

View File

@ -89,7 +89,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;
}
@ -112,7 +112,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;
}
@ -155,7 +155,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

@ -72,7 +72,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

@ -97,7 +97,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());
}
@ -119,7 +119,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

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

Some files were not shown because too many files have changed in this diff Show More