Fix concurrency bug with new mappings being added
This commit is contained in:
parent
29a74c125a
commit
4cf114b7ac
|
@ -25,8 +25,9 @@
|
|||
package de.bluecolored.bluemap.core.config;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
import de.bluecolored.bluemap.core.logger.Logger;
|
||||
import de.bluecolored.bluemap.core.mca.mapping.BiomeMapper;
|
||||
|
@ -37,7 +38,7 @@ import ninja.leaping.configurate.loader.ConfigurationLoader;
|
|||
public class BiomeConfig implements BiomeMapper {
|
||||
|
||||
private ConfigurationLoader<? extends ConfigurationNode> autopoulationConfigLoader;
|
||||
private HashMap<Integer, Biome> biomes;
|
||||
private Map<Integer, Biome> biomes;
|
||||
|
||||
public BiomeConfig(ConfigurationNode node) {
|
||||
this(node, null);
|
||||
|
@ -46,7 +47,7 @@ public class BiomeConfig implements BiomeMapper {
|
|||
public BiomeConfig(ConfigurationNode node, ConfigurationLoader<? extends ConfigurationNode> autopoulationConfigLoader) {
|
||||
this.autopoulationConfigLoader = autopoulationConfigLoader;
|
||||
|
||||
biomes = new HashMap<>();
|
||||
biomes = new ConcurrentHashMap<>(200, 0.5f, 8);
|
||||
|
||||
for (Entry<Object, ? extends ConfigurationNode> e : node.getChildrenMap().entrySet()){
|
||||
String id = e.getKey().toString();
|
||||
|
|
|
@ -25,9 +25,11 @@
|
|||
package de.bluecolored.bluemap.core.config;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
import com.google.common.base.Preconditions;
|
||||
|
||||
import de.bluecolored.bluemap.core.logger.Logger;
|
||||
import de.bluecolored.bluemap.core.mca.mapping.BlockIdMapper;
|
||||
|
@ -48,8 +50,8 @@ public class BlockIdConfig implements BlockIdMapper {
|
|||
public BlockIdConfig(ConfigurationNode node, ConfigurationLoader<? extends ConfigurationNode> autopoulationConfigLoader) {
|
||||
this.autopoulationConfigLoader = autopoulationConfigLoader;
|
||||
|
||||
numeralMappings = new HashMap<>();
|
||||
idMappings = new HashMap<>();
|
||||
numeralMappings = new ConcurrentHashMap<>(200, 0.5f, 8);
|
||||
idMappings = new ConcurrentHashMap<>(200, 0.5f, 8);
|
||||
|
||||
for (Entry<Object, ? extends ConfigurationNode> e : node.getChildrenMap().entrySet()){
|
||||
String key = e.getKey().toString();
|
||||
|
@ -135,7 +137,7 @@ public class BlockIdConfig implements BlockIdMapper {
|
|||
}
|
||||
|
||||
idMappings.put(idmeta, state);
|
||||
numeralMappings.put(numidmeta, state);
|
||||
Preconditions.checkArgument(numeralMappings.put(numidmeta, state) == null);
|
||||
|
||||
if (autopoulationConfigLoader != null) {
|
||||
synchronized (autopoulationConfigLoader) {
|
||||
|
|
|
@ -33,6 +33,7 @@ import com.google.common.cache.CacheLoader;
|
|||
import com.google.common.cache.LoadingCache;
|
||||
import com.google.common.collect.Multimap;
|
||||
import com.google.common.collect.MultimapBuilder;
|
||||
import com.google.common.collect.Multimaps;
|
||||
|
||||
import de.bluecolored.bluemap.core.logger.Logger;
|
||||
import de.bluecolored.bluemap.core.mca.mapping.BlockPropertiesMapper;
|
||||
|
@ -61,7 +62,7 @@ public class BlockPropertiesConfig implements BlockPropertiesMapper {
|
|||
this.resourcePack = resourcePack;
|
||||
this.autopoulationConfigLoader = autopoulationConfigLoader;
|
||||
|
||||
mappings = MultimapBuilder.hashKeys().arrayListValues().build();
|
||||
mappings = Multimaps.synchronizedListMultimap(MultimapBuilder.hashKeys().arrayListValues().build());
|
||||
|
||||
for (Entry<Object, ? extends ConfigurationNode> e : node.getChildrenMap().entrySet()){
|
||||
String key = e.getKey().toString();
|
||||
|
|
Loading…
Reference in New Issue