Removed stream usage from Attackable.

This commit is contained in:
MobiusDevelopment
2023-01-08 14:34:48 +00:00
parent 420b8409e5
commit 6e8a72c251
26 changed files with 546 additions and 52 deletions

View File

@@ -702,10 +702,19 @@ public class Attackable extends Npc
@Override
public void addAttackerToAttackByList(Creature creature)
{
if ((creature == null) || (creature == this) || getAttackByList().stream().anyMatch(o -> o.get() == creature))
if ((creature == null) || (creature == this))
{
return;
}
for (WeakReference<Creature> ref : getAttackByList())
{
if (ref.get() == creature)
{
return;
}
}
getAttackByList().add(new WeakReference<>(creature));
}
@@ -976,7 +985,16 @@ public class Attackable extends Npc
result.add(mostHated);
final Creature secondMostHatedFinal = secondMostHated;
if (getAttackByList().stream().anyMatch(o -> o.get() == secondMostHatedFinal))
boolean found = false;
for (WeakReference<Creature> ref : getAttackByList())
{
if (ref.get() == secondMostHatedFinal)
{
found = true;
break;
}
}
if (found)
{
result.add(secondMostHated);
}
@@ -984,6 +1002,7 @@ public class Attackable extends Npc
{
result.add(null);
}
return result;
}