mirror of
https://github.com/Minestom/Minestom.git
synced 2025-01-01 05:58:00 +01:00
Fix concurrent modify exception.
This commit is contained in:
parent
cc01a48cf1
commit
d12618af0f
@ -109,9 +109,7 @@ public class PerGroupChunkProvider extends ThreadProvider {
|
||||
|
||||
ArrayList<Future<?>> futures = new ArrayList<>();
|
||||
|
||||
instanceInstanceMap.entrySet().forEach(entry -> {
|
||||
final Instance instance = entry.getKey();
|
||||
final Map<LongSet, Instance> instanceMap = entry.getValue();
|
||||
instanceInstanceMap.forEach((instance, instanceMap) -> {
|
||||
|
||||
// True if the instance ended its tick call
|
||||
AtomicBoolean instanceUpdated = new AtomicBoolean(false);
|
||||
@ -157,7 +155,7 @@ public class PerGroupChunkProvider extends ThreadProvider {
|
||||
}
|
||||
|
||||
private Map<LongSet, Instance> getInstanceMap(Instance instance) {
|
||||
return instanceInstanceMap.computeIfAbsent(instance, inst -> new HashMap<>());
|
||||
return instanceInstanceMap.computeIfAbsent(instance, inst -> new ConcurrentHashMap<>());
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -70,4 +70,12 @@ public final class MathUtils {
|
||||
public static float setBetween(float number, float min, float max) {
|
||||
return number > max ? max : number < min ? min : number;
|
||||
}
|
||||
|
||||
public static int clamp(int value, int min, int max) {
|
||||
if (value < min) {
|
||||
return min;
|
||||
} else {
|
||||
return Math.min(value, max);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user