diff options
| author | shedaniel <daniel@shedaniel.me> | 2021-11-07 16:21:34 +0800 |
|---|---|---|
| committer | shedaniel <daniel@shedaniel.me> | 2021-11-07 16:21:34 +0800 |
| commit | f8fc41207ca444c0a90ae10d78a821831b245bc2 (patch) | |
| tree | a2a049cc4ead3157eb9d284027e12798f9e48c81 /runtime/src/main/java/me/shedaniel/rei/plugin | |
| parent | d1e91e2e2ffa317a52e659f2ca2b76800108f427 (diff) | |
| download | RoughlyEnoughItems-f8fc41207ca444c0a90ae10d78a821831b245bc2.tar.gz RoughlyEnoughItems-f8fc41207ca444c0a90ae10d78a821831b245bc2.tar.bz2 RoughlyEnoughItems-f8fc41207ca444c0a90ae10d78a821831b245bc2.zip | |
Fix #654
Diffstat (limited to 'runtime/src/main/java/me/shedaniel/rei/plugin')
| -rw-r--r-- | runtime/src/main/java/me/shedaniel/rei/plugin/client/runtime/PluginStageExecutionWatcher.java | 18 |
1 files changed, 11 insertions, 7 deletions
diff --git a/runtime/src/main/java/me/shedaniel/rei/plugin/client/runtime/PluginStageExecutionWatcher.java b/runtime/src/main/java/me/shedaniel/rei/plugin/client/runtime/PluginStageExecutionWatcher.java index 10326394c..86eddd5c0 100644 --- a/runtime/src/main/java/me/shedaniel/rei/plugin/client/runtime/PluginStageExecutionWatcher.java +++ b/runtime/src/main/java/me/shedaniel/rei/plugin/client/runtime/PluginStageExecutionWatcher.java @@ -40,7 +40,7 @@ import java.util.*; import java.util.stream.Collectors; public class PluginStageExecutionWatcher implements HintProvider { - private Map<PluginManager<?>, Set<ReloadStage>> allStages = new HashMap<>(); + private final Map<PluginManager<?>, Set<ReloadStage>> allStages = new HashMap<>(); public <T extends REIPlugin<?>> Reloadable<? extends T> reloadable(PluginManager<?> manager) { return new Reloadable<>() { @@ -53,17 +53,21 @@ public class PluginStageExecutionWatcher implements HintProvider { @Override public void startReload(ReloadStage stage) { - Set<ReloadStage> stages = allStages.computeIfAbsent(manager, $ -> new HashSet<>()); - if (stage.ordinal() == 0) stages.clear(); - stages.add(stage); + synchronized (allStages) { + Set<ReloadStage> stages = allStages.computeIfAbsent(manager, $ -> new HashSet<>()); + if (stage.ordinal() == 0) stages.clear(); + stages.add(stage); + } } }; } public Set<ReloadStage> notVisited() { - Set<ReloadStage> notVisited = new HashSet<>(Arrays.asList(ReloadStage.values())); - notVisited.removeIf(stage -> allStages.values().stream().allMatch(stages -> stages.contains(stage))); - return notVisited; + synchronized (allStages) { + Set<ReloadStage> notVisited = new HashSet<>(Arrays.asList(ReloadStage.values())); + notVisited.removeIf(stage -> allStages.values().stream().allMatch(stages -> stages.contains(stage))); + return notVisited; + } } @Override |
