Replaced instanceof L2Attackable with isAttackable method.

This commit is contained in:
MobiusDev
2018-07-02 00:55:13 +00:00
parent 6c1d37f4ae
commit 0b09d49f8d
51 changed files with 73 additions and 86 deletions

View File

@@ -62,7 +62,7 @@ public class L2NpcActionShift implements IActionShiftHandler
html.replace("%lvl%", String.valueOf(npc.getTemplate().getLevel()));
html.replace("%name%", npc.getTemplate().getName());
html.replace("%tmplid%", String.valueOf(npc.getTemplate().getId()));
html.replace("%aggro%", String.valueOf((target instanceof L2Attackable) ? ((L2Attackable) target).getAggroRange() : 0));
html.replace("%aggro%", String.valueOf(target.isAttackable() ? ((L2Attackable) target).getAggroRange() : 0));
html.replace("%hp%", String.valueOf((int) npc.getCurrentHp()));
html.replace("%hpmax%", String.valueOf(npc.getMaxHp()));
html.replace("%mp%", String.valueOf((int) npc.getCurrentMp()));

View File

@@ -18,7 +18,6 @@ package handlers.effecthandlers;
import com.l2jmobius.gameserver.ai.CtrlIntention;
import com.l2jmobius.gameserver.model.StatsSet;
import com.l2jmobius.gameserver.model.actor.L2Attackable;
import com.l2jmobius.gameserver.model.actor.L2Character;
import com.l2jmobius.gameserver.model.effects.AbstractEffect;
import com.l2jmobius.gameserver.model.effects.L2EffectType;
@@ -50,7 +49,7 @@ public final class GetAgro extends AbstractEffect
@Override
public void instant(L2Character effector, L2Character effected, Skill skill, L2ItemInstance item)
{
if (effected instanceof L2Attackable)
if ((effected != null) && effected.isAttackable())
{
effected.getAI().setIntention(CtrlIntention.AI_INTENTION_ATTACK, effector);
}

View File

@@ -88,7 +88,7 @@ public final class L2WorldRegion
{
for (L2Object o : _visibleObjects.values())
{
if (o instanceof L2Attackable)
if (o.isAttackable())
{
c++;
final L2Attackable mob = (L2Attackable) o;
@@ -123,7 +123,7 @@ public final class L2WorldRegion
{
for (L2Object o : _visibleObjects.values())
{
if (o instanceof L2Attackable)
if (o.isAttackable())
{
c++;
// Start HP/MP/CP Regeneration task

View File

@@ -58,7 +58,7 @@ public class ConditionPlayerCanSweep extends Condition
{
skill.forEachTargetAffected(sweeper, effected, o ->
{
if (o instanceof L2Attackable)
if ((o != null) && o.isAttackable())
{
final L2Attackable target = (L2Attackable) o;
if (target.isDead())

View File

@@ -3206,7 +3206,7 @@ public abstract class AbstractScript extends ManagedScript implements IEventTime
*/
protected void addAttackPlayerDesire(L2Npc npc, L2Playable target, int desire)
{
if (npc instanceof L2Attackable)
if (npc.isAttackable())
{
((L2Attackable) npc).addDamageHate(target, 0, desire);
}