From f8d499f3143f834648276afec6f604a983e64948 Mon Sep 17 00:00:00 2001 From: MagicBot Date: Wed, 15 Mar 2023 09:39:17 -0400 Subject: [PATCH] Fixed Concurrent Modification issue. --- src/engine/ai/MobileFSM.java | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/engine/ai/MobileFSM.java b/src/engine/ai/MobileFSM.java index 1a28339a..809ac396 100644 --- a/src/engine/ai/MobileFSM.java +++ b/src/engine/ai/MobileFSM.java @@ -1648,6 +1648,7 @@ public class MobileFSM { // if done previously in canCast(); ArrayList powerTokens; + ArrayList purgeTokens; PlayerCharacter target = (PlayerCharacter) mob.getCombatTarget(); if (mob.getMobBase().getFlags().contains(Enum.MobFlagType.CALLSFORHELP)) @@ -1656,9 +1657,10 @@ public class MobileFSM { // Generate a list of tokens from the mob powers for this mobile. powerTokens = new ArrayList<>(mob.mobPowers.keySet()); + purgeTokens = new ArrayList<>(); // If player has this effect on them already then remove the token - // from the list of mob powers + // from our list of mob powers for (int powerToken : powerTokens){ @@ -1669,10 +1671,12 @@ public class MobileFSM { String des = act.stackType; if (target.getEffects() != null && target.getEffects().containsKey(des)) - powerTokens.remove(Integer.valueOf(powerToken)); + purgeTokens.add(powerToken); } } + powerTokens.removeAll(purgeTokens); + // Pick random spell from our list of powers int powerToken = powerTokens.get(ThreadLocalRandom.current().nextInt(powerTokens.size()));