8000 Fix a rare crash with a concurrent modification of scaled health attr… · PaperMC/Paper@30046e0 · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Commit 30046e0

Browse files
Fix a rare crash with a concurrent modification of scaled health attributes (#12002)
1 parent 6b7650d commit 30046e0

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
import java.util.Date;
2525
import java.util.HashMap;
2626
import java.util.HashSet;
27+
import java.util.Iterator;
2728
import java.util.LinkedHashMap;
2829
import java.util.LinkedList;
2930
import java.util.List;
@@ -2858,9 +2859,11 @@ public void injectScaledMaxHealth(Collection<AttributeInstance> collection, bool
28582859
if (!this.scaledHealth && !force) {
28592860
return;
28602861
}
2861-
for (AttributeInstance genericInstance : collection) {
2862+
Iterator<AttributeInstance> iterator = collection.iterator();
2863+
while (iterator.hasNext()) {
2864+
AttributeInstance genericInstance = iterator.next();
28622865
if (genericInstance.getAttribute() == Attributes.MAX_HEALTH) {
2863-
collection.remove(genericInstance);
2866+
iterator.remove();
28642867
break;
28652868
}
28662869
}

0 commit comments

Comments
 (0)
0