Skip to content

Commit

Permalink
Fixed setting generator rate to 0 while having it as an upgrade rewar…
Browse files Browse the repository at this point in the history
…d causing it to reset after a restart
  • Loading branch information
OmerBenGera committed Jan 14, 2023
1 parent 081c140 commit 908e65c
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions src/main/java/com/bgsoftware/superiorskyblock/island/SIsland.java
Expand Up @@ -3360,12 +3360,19 @@ public void removeGeneratorAmount(Key key, World.Environment environment) {
if (worldGeneratorRates == null)
return;

Value<Integer> oldGeneratorRate = worldGeneratorRates.remove(key);
Value<Integer> oldGeneratorRate = worldGeneratorRates.get(key);

if (oldGeneratorRate == null)
if (oldGeneratorRate == null || oldGeneratorRate.get() <= 0)
return;

IslandsDatabaseBridge.removeGeneratorRate(this, environment, key);
if (oldGeneratorRate instanceof SyncedValue) {
// In case the old rate was upgrade-synced, we want to keep it in DB and cache as a 0 rate.
IslandsDatabaseBridge.saveGeneratorRate(this, environment, key, 0);
worldGeneratorRates.put(key, Value.fixed(0));
} else {
IslandsDatabaseBridge.removeGeneratorRate(this, environment, key);
worldGeneratorRates.remove(key);
}
}

/*
Expand Down

0 comments on commit 908e65c

Please sign in to comment.