diff --git a/src/main/java/com/bgsoftware/superiorskyblock/island/SIsland.java b/src/main/java/com/bgsoftware/superiorskyblock/island/SIsland.java index 8ab47de46..d2038d031 100644 --- a/src/main/java/com/bgsoftware/superiorskyblock/island/SIsland.java +++ b/src/main/java/com/bgsoftware/superiorskyblock/island/SIsland.java @@ -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> entry : upgradeLevelGeneratorRates.entrySet()) { + Key block = entry.getKey(); + Value rate = entry.getValue(); + Value 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> 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); } - }); + } } }); }