Skip to content

Commit

Permalink
Fixed issues with syncing generator rates from upgrades (#1398)
Browse files Browse the repository at this point in the history
  • Loading branch information
OmerBenGera committed Oct 6, 2022
1 parent fc21b77 commit c11e4c2
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions src/main/java/com/bgsoftware/superiorskyblock/island/SIsland.java
Expand Up @@ -3913,18 +3913,21 @@ private void syncUpgrade(SUpgradeLevel upgradeLevel, boolean overrideCustom) {
if (worldGeneratorRates != null && !upgradeLevelGeneratorRates.isEmpty())
worldGeneratorRates.entrySet().removeIf(entry -> entry.getValue() instanceof SyncedValue);

upgradeLevelGeneratorRates.forEach((block, rate) -> {
for (Map.Entry<Key, Value<Integer>> entry : upgradeLevelGeneratorRates.entrySet()) {
Key block = entry.getKey();
Value<Integer> rate = entry.getValue();

Value<Integer> currentValue = worldGeneratorRates == null ? null : worldGeneratorRates.get(block);
if (currentValue == null || ((overrideCustom || currentValue instanceof SyncedValue) && currentValue.get() < rate.get())) {
if (currentValue == null || ((overrideCustom || currentValue instanceof SyncedValue) &&
currentValue.get() < rate.get())) {
if (worldGeneratorRates == null) {
KeyMap<Value<Integer>> newWorldGeneratorRates = KeyMapImpl.createConcurrentHashMap();
cobbleGeneratorValues.put(environment, newWorldGeneratorRates);
newWorldGeneratorRates.put(block, rate);
} else {
worldGeneratorRates.put(block, rate);
worldGeneratorRates = KeyMapImpl.createConcurrentHashMap();
cobbleGeneratorValues.put(environment, worldGeneratorRates);
}

worldGeneratorRates.put(block, rate);
}
});
}
}
});
}
Expand Down

0 comments on commit c11e4c2

Please sign in to comment.