Skip to content

Commit

Permalink
Fixes #55
Browse files Browse the repository at this point in the history
  • Loading branch information
BONNe committed Jul 5, 2020
1 parent f927c69 commit d898eda
Showing 1 changed file with 8 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -541,14 +541,19 @@ else if (generatorTier.getRequiredMinIslandLevel() <= this.getIslandLevel(island

this.updateMaxGeneratorCount(island, dataObject);

if (dataObject.getMaxGeneratorCount() < dataObject.getActiveGeneratorList().size())
if (dataObject.getMaxGeneratorCount() > 0 &&
dataObject.getMaxGeneratorCount() < dataObject.getActiveGeneratorList().size())
{
// There are more active generators then allowed.
// Start to remove from first element.

while (dataObject.getActiveGeneratorList().size() != dataObject.getMaxGeneratorCount())
Iterator<GeneratorTierObject> activeGenerators =
new ArrayList<>(dataObject.getActiveGeneratorList()).iterator();

while (dataObject.getActiveGeneratorList().size() > dataObject.getMaxGeneratorCount() &&
activeGenerators.hasNext())
{
dataObject.getActiveGeneratorList().iterator().remove();
dataObject.getActiveGeneratorList().remove(activeGenerators.next());
}
}

Expand Down

0 comments on commit d898eda

Please sign in to comment.