Skip to content

Commit

Permalink
Change AbilityCache to use ConcurrentHashMap
Browse files Browse the repository at this point in the history
  • Loading branch information
BlakeBr0 committed Dec 29, 2024
1 parent 8bfb4b1 commit 3ed35d7
Showing 1 changed file with 3 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,12 @@
import java.util.HashMap;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
import java.util.stream.Collectors;

public class AbilityCache {
private static final HashMap<String, Runnable> EMPTY_MAP = new HashMap<>();
private final Map<String, Map<String, Runnable>> cache = new HashMap<>();
private final Map<String, Map<String, Runnable>> cache = new ConcurrentHashMap<>();

/**
* Add a user to the cache for the specified augment, meaning they have it equipped currently
Expand All @@ -30,7 +31,7 @@ public void add(Augment augment, Player player, Runnable onRemove) {
*/
public void add(String augment, Player player, Runnable onRemove) {
var key = getPlayerKey(player);
this.cache.computeIfAbsent(augment, s -> new HashMap<>()).put(key, onRemove);
this.cache.computeIfAbsent(augment, s -> new ConcurrentHashMap<>()).put(key, onRemove);
}

/**
Expand Down

0 comments on commit 3ed35d7

Please sign in to comment.