Removal of various conversions to arrays.

This commit is contained in:
MobiusDevelopment
2021-04-22 01:53:19 +00:00
parent 6d16bebe1a
commit 6a3556614a
881 changed files with 3876 additions and 3980 deletions

View File

@@ -475,14 +475,14 @@ public class Baium extends Quest
return null;
}
final Object[] characters = result.toArray();
final QuestTimer timer = getQuestTimer("clean_player", npc, null);
if (timer != null)
{
timer.cancel();
}
startQuestTimer("clean_player", 20000, npc, null);
return (Creature) characters[Rnd.get(characters.length)];
return result.get(Rnd.get(result.size()));
}
public synchronized void callSkillAI(NpcInstance npc)

View File

@@ -966,8 +966,7 @@ public class Valakas extends Quest
}
if (!result.isEmpty())
{
final Object[] characters = result.toArray();
return (Creature) characters[Rnd.get(characters.length)];
return result.get(Rnd.get(result.size()));
}
return null;
}

View File

@@ -118,38 +118,34 @@ public class Monastery extends Quest
result.add((Playable) obj);
}
}
if (!result.isEmpty())
for (Object obj : result)
{
final Object[] characters = result.toArray();
for (Object obj : characters)
final Playable target = (Playable) (obj instanceof PlayerInstance ? obj : ((Summon) obj).getOwner());
if ((target.getActiveWeaponInstance() == null) || ((target instanceof PlayerInstance) && ((PlayerInstance) target).isSilentMoving()) || ((target instanceof Summon) && ((Summon) target).getOwner().isSilentMoving()))
{
final Playable target = (Playable) (obj instanceof PlayerInstance ? obj : ((Summon) obj).getOwner());
if ((target.getActiveWeaponInstance() == null) || ((target instanceof PlayerInstance) && ((PlayerInstance) target).isSilentMoving()) || ((target instanceof Summon) && ((Summon) target).getOwner().isSilentMoving()))
continue;
}
if ((target.getActiveWeaponInstance() != null) && !npc.isInCombat() && (npc.getTarget() == null))
{
npc.setTarget(target);
npc.broadcastPacket(new CreatureSay(npc.getObjectId(), ChatType.GENERAL, npc.getName(), TEXT[0]));
switch (npc.getNpcId())
{
continue;
}
if ((target.getActiveWeaponInstance() != null) && !npc.isInCombat() && (npc.getTarget() == null))
{
npc.setTarget(target);
npc.broadcastPacket(new CreatureSay(npc.getObjectId(), ChatType.GENERAL, npc.getName(), TEXT[0]));
switch (npc.getNpcId())
case 22124:
case 22126:
case 22127:
{
case 22124:
case 22126:
case 22127:
{
final Skill skill = SkillTable.getInstance().getSkill(4589, 8);
npc.doCast(skill);
break;
}
default:
{
npc.setRunning(true);
((Attackable) npc).addDamageHate(target, 0, 999);
npc.getAI().setIntention(CtrlIntention.AI_INTENTION_ATTACK, target);
break;
}
final Skill skill = SkillTable.getInstance().getSkill(4589, 8);
npc.doCast(skill);
break;
}
default:
{
npc.setRunning(true);
((Attackable) npc).addDamageHate(target, 0, 999);
npc.getAI().setIntention(CtrlIntention.AI_INTENTION_ATTACK, target);
break;
}
}
}