Skip to content

Commit

Permalink
Fixes #86.
Browse files Browse the repository at this point in the history
There was a missing sorting for default generators.
This should be solved now.
  • Loading branch information
BONNe committed Feb 23, 2021
1 parent 15a2ce8 commit eb7862f
Showing 1 changed file with 8 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -505,16 +505,18 @@ else if (o1.getGeneratorType() != o2.getGeneratorType())
}

// Find default generator from cache.
// Filter all default generators
// Filter generators with necessary type.
// Filter generators that starts with name.
// Sort generators by priority, type and name in reversed order
// Return return the generator tier with max value or null
return this.generatorTierCache.values().stream().
// Filter all default generators
filter(GeneratorTierObject::isDefaultGenerator).
// Filter generators with necessary type.
filter(generator -> generator.getGeneratorType().includes(generatorType)).
// Filter generators that starts with name.
filter(generator -> generator.getUniqueId().startsWith(gameMode.toLowerCase())).
// Return first
findFirst().
// Return null if none is find.
max(Comparator.comparingInt(GeneratorTierObject::getPriority).
thenComparing(GeneratorTierObject::getGeneratorType).
thenComparing(Comparator.comparing(GeneratorTierObject::getFriendlyName).reversed())).
orElse(null);
}

Expand Down

0 comments on commit eb7862f

Please sign in to comment.