mirror of
https://github.com/KAMKEEL/CustomNPC-Plus.git
synced 2026-11-12 04:57:27 +00:00
NpcAPI:
-Further fix to concurrent modification exception
This commit is contained in:
1 parent
65f3f8fc74
commit
45a139ea68
1 file changed
+8
-4
@@ -372,13 +372,17 @@ public class NpcAPI extends AbstractNpcAPI {
|
||||
|
||||
long time = System.currentTimeMillis();
|
||||
scriptStack.lastAccessed = time;
|
||||
Iterator<Map.Entry<ItemStack, ScriptItemStack>> iterator = scriptItemCache.entrySet().iterator();
|
||||
while (iterator.hasNext()) {
|
||||
Map.Entry<ItemStack, ScriptItemStack> entry = iterator.next();
|
||||
|
||||
List<ItemStack> keysToRemove = new ArrayList<>();
|
||||
for (Map.Entry<ItemStack, ScriptItemStack> entry : scriptItemCache.entrySet()) {
|
||||
if (time - entry.getValue().lastAccessed > 20000) {
|
||||
iterator.remove();
|
||||
keysToRemove.add(entry.getKey());
|
||||
}
|
||||
}
|
||||
for (ItemStack key : keysToRemove) {
|
||||
scriptItemCache.remove(key);
|
||||
}
|
||||
|
||||
scriptItemCache.put(itemstack,scriptStack);
|
||||
|
||||
return scriptStack;
|
||||
|
||||
Reference in new issue
Block a user